Skip to content

Instantly share code, notes, and snippets.

@shishirsharma
Created April 8, 2017 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shishirsharma/f0b5a95218f0a500d48f61dece5e5562 to your computer and use it in GitHub Desktop.
Save shishirsharma/f0b5a95218f0a500d48f61dece5e5562 to your computer and use it in GitHub Desktop.
Dockerizing Ruby on Rails
version: '2'
services:
app:
build: .
image: localhost:5000/nolan
command: bin/rails server --port 3000 --binding 0.0.0.0
environment:
- BUNDLE_PATH=/root/bundle
- DATABASE_URL=postgres://postgres:@db/fblb
- AWS_KEY=AKIAEROO7DAUAFGW2ECQ
- AWS_SECRET=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
- AWS_REGION=ap-southeast-1
- SPRING_SOCKET=/home/docker/apps/nolan/current/tmp/spring
volumes:
- .:/home/docker/apps/nolan/current
- bundle_volume:/root/bundle
volumes_from:
- bundle
ports:
- "3000:3000"
depends_on:
- db
- redis
stdin_open: true
tty: true
db:
# image: localhost:5000/postgres:9.4
image: postgres:9.4
environment:
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- ./tmp/db:/var/lib/postgresql/data/pgdata
ports:
- "5432"
redis:
# image: localhost:5000/redis
image: redis
ports:
- "6379"
volumes:
bundle_volume:
external:
name: bundle_volume
docker volume create --name=bundle_volume
docker-compose build
docker-compose run --rm app bundle install
docker-compose run --rm app bundle exec rake db:setup
docker-compose up -d
docker-compose ps
FROM ruby:2.3
MAINTAINER backend@nuvoex.com
# https://blog.codeship.com/running-rails-development-environment-docker/
# Install apt based dependencies required to run Rails as
# well as RubyGems. As the Ruby image itself is based on a
# Debian image, we use apt-get to install those.
RUN apt-get update && apt-get install -y build-essential
# For postgres
RUN apt-get install -y libpq-dev
# For nokogiri
RUN apt-get install -y libxml2-dev libxslt1-dev
# For a JS runtime
RUN apt-get install -y nodejs
# Configure the main working directory. This is the base
# directory used in any further RUN, COPY, and ENTRYPOINT
# commands.
ENV NOLAN_HOME /home/docker/apps/nolan/current
RUN mkdir -p $NOLAN_HOME
WORKDIR $NOLAN_HOME
ENV BUNDLE_PATH /root/bundle
# Copy the main application.
# ADD . $NOLAN_HOME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment