Skinny rails app built using some example that can be found on the internets. Modified to actually do some work that you'll find in a common rails app:
- database integration
ActiveRecord
-based models- views
- controllers
- specs
- rake tasks to manage db
The idea of the app: Render quotes randomly from database
This repo includes few files that will help you get started with running it on docker:
- Dockerfile - contains definition of the base image for this app (
rails:onbuild
) docker-compose.yml
- file that includes dependency services required for application to run, i.e. mysqldocker-compose.development.yml
- this is same file asdocker-compose.yml
, but tailored for execution of specs and running service in development environment. By setting volume from your current directory into container's directory, so that you always have latest code as soon as you save the change in the file.
To get up and running on your machine, you'd need to install:
- docker
- docker-machine (to provision docker hosts on your local or in the cloud)
- docker-compose (to orchestrate containers)
If you want to learn more and don't know where to start, check out this excellent guide on Getting started with docker-compose for Development environment
- Clone repo
- Create docker host on your laptop
docker-machine create -d virtualbox --virtualbox-memory "2048" quotes
- Inside repo, start application:
docker-compose up -d
It will pull, build and then launch mysql and web containers defined indocker-compose.yml
file - Create database and seed initial data:
docker-compose run web rake db:reset
Be careful, if it's 2nd time you're running it - your database will be deleted, created again and schema with data reloaded.
docker-compose -f docker-compose.development.yml run -e RAILS_ENV=test web rspec
This command will launch container and execute specs.
Of course this rails application like any other can be deployed to any PAAS product, i.e. heroku.
- Controllers and Models are located in
app.rb
file - Views are located in
views
directory - Specs are in their normal location -
spec
directory - Database configuration is in
db/database.yml
(vsconfig/database.yml
with default rails structure) - Database migrations and seeds are in
db
direcotry
To have a lightweight example of rails app to play with different options for deployment. It must have traits similar to common rails app:
- integration with external services (i.e. database)
- tests
- views