Skip to content

Instantly share code, notes, and snippets.

@wwwbruno
Last active January 21, 2016 14:11
Show Gist options
  • Save wwwbruno/b5cb5c4b05d03d605b83 to your computer and use it in GitHub Desktop.
Save wwwbruno/b5cb5c4b05d03d605b83 to your computer and use it in GitHub Desktop.
Dockerfile and docker-compose.yml for Rails Application
db:
image: postgres:9.4.4
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/myapp
ports:
- "3000:3000"
links:
- db
FROM ruby:2.2.1
RUN apt-get update -qq && apt-get install -y build-essential
# for postgres
RUN apt-get install -y libpq-dev
# for capybara-webkit
RUN apt-get install -y libqt4-webkit libqt4-dev xvfb
# for a JS runtime
RUN apt-get install -y nodejs
RUN mkdir /myapp
WORKDIR /myapp
ADD Gemfile /myapp/Gemfile
ADD Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
ADD . /myapp
# build the container
docker-compose build
# setup the database
docker-compose run web rake db:setup
# run the application
docker-compose up
# open on your browser
# http://DOCKER_VM_IP:3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment