Last active
May 17, 2019 09:45
-
-
Save alexesDev/f1630f30f10dbb95b18d2da03dc3ec61 to your computer and use it in GitHub Desktop.
Multi-stage Dockerfile for Rails 5.2
This file contains hidden or 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
.git | |
.gitignore | |
Dockerfile | |
log | |
tmp | |
public/system |
This file contains hidden or 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.6.3-alpine3.9 AS base | |
RUN apk --update add tzdata postgresql-dev libxslt-dev libxml2-dev imagemagick | |
WORKDIR /app | |
# bundle install | |
FROM base as bundler | |
RUN apk --update add build-base | |
WORKDIR /app | |
COPY Gemfile Gemfile.lock ./ | |
RUN echo 'gem: --no-rdoc --no-ri' > ~/.gemrc && \ | |
bundle install --no-cache --without development test --jobs 2 | |
# build assets | |
FROM bundler AS assets | |
RUN apk --update add nodejs yarn | |
ENV RAILS_ENV=production | |
COPY config ./config | |
COPY package.json Rakefile ./ | |
COPY app/assets ./app/assets | |
RUN SKIP_ALL_ROUTES=yes bundle exec rake assets:precompile | |
# final image | |
FROM base as final | |
ENV EXECJS_RUNTIME=Disabled RAILS_ENV=production | |
COPY --from=bundler /usr/local/bundle /usr/local/bundle | |
COPY --from=assets /app/public/assets ./public/assets | |
COPY . . | |
CMD ["/app/bin/rails", "server"] |
This file contains hidden or 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
Rails.application.routes.draw do | |
return if ENV['SKIP_ALL_ROUTES'] | |
# ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment