Created
July 23, 2015 13:37
-
-
Save crohr/7a0ddfe8767a6f0eaea9 to your computer and use it in GitHub Desktop.
Fully-working Dockerfile for a Rails app
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
FROM ruby:2.1 | |
RUN apt-get update && apt-get install -y nodejs | |
RUN mkdir -p /usr/src/app | |
RUN useradd -d /usr/src/app -m app | |
RUN chown -R app /usr/src/app | |
RUN chown -R app /usr/local/bundle | |
USER root | |
WORKDIR /usr/src/app | |
COPY Gemfile ./Gemfile | |
COPY Gemfile.lock ./Gemfile.lock | |
RUN chown -R app.app . | |
USER app | |
RUN bundle install | |
USER root | |
COPY . /usr/src/app | |
RUN chown -R app.app . | |
USER app | |
RUN RAILS_ENV=production bundle exec rake assets:precompile --trace | |
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
This correctly handles both production and development mode, in that in development mode you would mount your local copy of the code with:
The precompiled assets in
public/assets
would thus be erased, and subsequentbundle install
would reuse the ones already installed in/usr/local/bundle
.