Skip to content

Instantly share code, notes, and snippets.

@rachelmyers
Created November 7, 2016 21:34
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 rachelmyers/e8c7cbc6a1fbff4aef289de73d50267f to your computer and use it in GitHub Desktop.
Save rachelmyers/e8c7cbc6a1fbff4aef289de73d50267f to your computer and use it in GitHub Desktop.
Rails with a Puma server example
# Our base image is Ruby 2.2, to be run on Amazon Linux.
FROM ruby:2.2
# 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 AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_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 AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} RAILS_ENV=production assets:precompile && \
# Clean up build package
rm -rf /usr/local/lib/ruby/gems/*/cache/* && \
rm -rf ~/.gem
EXPOSE 80
# Run the application.
CMD puma --port 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment