--
- Create a folder called
demo
mkdir demo
- Create a
Gemfile
with the following contents
ruby '2.4.4'
source 'https://rubygems.org'
- Run:
touch Gemfile.lock
- Create a
Dockerfile
with the following contents
FROM ruby:2.4
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /demo
WORKDIR /demo
COPY Gemfile /demo/Gemfile
COPY Gemfile.lock /demo/Gemfile.lock
RUN bundle install
COPY . /demo
- Create a
docker-compose.yml
with the following contents
version: '3'
services:
db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/demo
ports:
- "3000:3000"
depends_on:
- db
- Run
docker-compose run web rails new . --force --database=postgresql
- Edit the
config/database.yml
file and replace the default section with:
default: &default
adapter: postgresql
encoding: unicode
user: postgres
password:
host: db
- Run
docker-compose run web rake db:create
docker-compose up