Skip to content

Instantly share code, notes, and snippets.

@rachelmyers
Last active October 7, 2016 01:16
Show Gist options
  • Save rachelmyers/5a7e0daad6b0599c6aa5b0feb72f534f to your computer and use it in GitHub Desktop.
Save rachelmyers/5a7e0daad6b0599c6aa5b0feb72f534f to your computer and use it in GitHub Desktop.
An annotated Dockerfile for Rails, running Ruby 2.2.5
# 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