Created
April 8, 2017 16:51
-
-
Save shishirsharma/f0b5a95218f0a500d48f61dece5e5562 to your computer and use it in GitHub Desktop.
Dockerizing Ruby on Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ruby:2.3 | |
MAINTAINER [email protected] | |
# 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