Skip to content

Instantly share code, notes, and snippets.

@gottfrois
Created September 6, 2018 09:00
Show Gist options
  • Save gottfrois/2797b52c1f154706dc06ffbf7ddd96dd to your computer and use it in GitHub Desktop.
Save gottfrois/2797b52c1f154706dc06ffbf7ddd96dd to your computer and use it in GitHub Desktop.
medium-multi-stage-dockerfile-compiler-stage
###############################
# Stage compiler
FROM runner as compiler
LABEL description="Builds a compiler image used to compile assets"
# Copy cached compiled assets to avoid re-compiling them
# We use latest compiler image to get already compiled assets
# and save lots of time on assets compilation for this new image
COPY --chown=app:app --from=my-app:compiler /home/app/public /home/app/public
COPY --chown=app:app --from=my-app:compiler /home/app/tmp /home/app/tmp
# Env variables required to run rake assets:precompile
ARG ASSET_HOST
ARG ENV=production
# Precompile assets and keep the cache for future releases
RUN ASSET_HOST=$ASSET_HOST \
RAILS_ENV=$ENV \
bundle exec rake assets:precompile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment