Skip to content

Instantly share code, notes, and snippets.

@pinglamb
Created August 8, 2016 03:01
Show Gist options
  • Save pinglamb/d664e99ae0158e254b50f9d83cf7f60f to your computer and use it in GitHub Desktop.
Save pinglamb/d664e99ae0158e254b50f9d83cf7f60f to your computer and use it in GitHub Desktop.
Rails Docker Deployment
FROM ensogo/passenger-ruby23:0.9.18
MAINTAINER developers@ensogo.com
ENV HOME /root
CMD ["/sbin/my_init"]
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-get update
# Upgrade Passenger
RUN apt-get install -y -o Dpkg::Options::="--force-confold" nginx-extras passenger
RUN mkdir -p /home/app
WORKDIR /home/app
ADD docker/freeze/Gemfile /home/app/Gemfile
ADD docker/freeze/Gemfile.lock /home/app/Gemfile.lock
RUN bundle install --binstubs --deployment --without development test --jobs 2
ADD Gemfile /home/app/Gemfile
ADD Gemfile.lock /home/app/Gemfile.lock
RUN bundle install --binstubs --deployment --without development test --jobs 2
ENV RAILS_ENV production
RUN rm -f /etc/service/nginx/down
RUN unlink /etc/nginx/sites-enabled/default
ADD docker/nginx.conf /etc/nginx/nginx.conf
ADD docker/nginx-app.conf /etc/nginx/sites-enabled/app.conf
ADD docker/nginx-env.conf /etc/nginx/main.d/nginx-env.conf
# Init Scripts
RUN mkdir -p /etc/my_init.d
ADD docker/init/01_permissions /etc/my_init.d/01_permissions
ADD docker/init/02_assets /etc/my_init.d/02_assets
RUN chmod +x /etc/my_init.d/*
# Runit Service
# RUN mkdir /etc/service/sidekiq
# ADD docker/runit/sidekiq /etc/service/sidekiq/run
# RUN chmod +x /etc/service/sidekiq/run
# Logrotate
ADD docker/logrotate.conf /etc/logrotate.d/app
VOLUME ["/home/app/log", "/home/app/public/assets", "/home/app/tmp/cache"]
WORKDIR /home/app
ADD config.ru /home/app/config.ru
ADD Rakefile /home/app/Rakefile
ADD bin /home/app/bin
ADD public /home/app/public
ADD lib /home/app/lib
ADD vendor /home/app/vendor
ADD db /home/app/db
ADD config /home/app/config
ADD docker/redis_cache.yml /home/app/config/redis_cache.yml
ADD docker/redis_storage.yml /home/app/config/redis_storage.yml
ADD docker/elasticsearch.yml /home/app/config/elasticsearch.yml
ADD app /home/app/app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment