Create a Gemfile with content
source 'source 'https://rubygems.org'
gem 'rails', '4.2.7.1'
Create an empty file 'Gemfile.lock'
Create file 'DockerFile'.
Create file 'docker-compose.yml'
Add DockerFile below lines for setting up the app.
From ruby:2.3.0
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /noteapp
WORKDIR /noteapp
ADD Gemfile /noteapp/Gemfile
ADD Gemfile.lock /noteapp/Gemfile.lock
RUN bundle install
ADD ./noteapp
Add the docker compose file https://gist.github.com/dineshsprabu/973a1a723fab711138c7c96bd2ba0264. Check the contents to understand.
Run 'docker-compose run app rails new . --force --database=mysql --skip-bundle'.
This will install the rails new app.
Now edit the database.yml file and set database configuration the use environment variable configured on docker-compose.yml.
Now run 'docker-compose build' and see the container being created.
Run 'docker-compose run --rm app rake db:migrate' for db migrate.
We can run any rake task like same above.
Run 'docker-compose up' for bringing up the container.
Now we should be able to access http://localhost:3001 as per our compose file.