Skip to content

Instantly share code, notes, and snippets.

@imjching
Created March 4, 2016 07:10
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 imjching/58450db042db91be9e48 to your computer and use it in GitHub Desktop.
Save imjching/58450db042db91be9e48 to your computer and use it in GitHub Desktop.
Utilizing Docker's caching system
# Choose the official Ruby 2.3.0 image as our starting point
FROM ruby:2.3.0
# Run updates for nokogiri and JS runtime
RUN apt-get update -qq && apt-get install -y build-essential libxml2-dev libxslt1-dev nodejs
# Cleanup
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Set up working directory
RUN mkdir /app
# Copy Gemfiles and install gems
WORKDIR /tmp
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install
# Everything up to here was cached. This includes
# the bundle install, unless the Gemfiles changed.
# Change back to app directory
WORKDIR /app
ADD . /app # optional if we mount local volumes to /app
# Start the server
CMD ["rails", "server", "-b", "0.0.0.0"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment