Last active
October 7, 2016 01:16
-
-
Save rachelmyers/5a7e0daad6b0599c6aa5b0feb72f534f to your computer and use it in GitHub Desktop.
An annotated Dockerfile for Rails, running Ruby 2.2.5
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
# Our base image is Ruby 2.2; it will run on Amazon Linux. | |
FROM ruby:2.2 | |
# This isn't required, but give yourself some credit | |
MAINTAINER Your Name Here <Your Email Here> | |
# Install packages | |
RUN apt-get update && apt-get install -y \ | |
git \ | |
nodejs \ | |
tzdata | |
# Copy your application into the container. | |
COPY . . | |
# Declare arguments that will vary by environment so we can pass them in | |
ARG ASSET_HOST | |
ARG SECRET_KEY | |
# Build your application. | |
RUN \ | |
# Install application gems. | |
bundle install --jobs 4 --without development test --with production && \ | |
# Precompile Rails assets, using the secret keys | |
bundle exec rake ASSET_HOST=${ASSET_HOST} SECRET_KEY=${SECRET_KEY} RAILS_ENV=production assets:precompile && \ | |
# Clean up build package | |
rm -rf /usr/local/lib/ruby/gems/*/cache/* && \ | |
rm -rf ~/.gem | |
# Run the application. | |
CMD bin/rails server --port 3000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment