Bläddra i källkod

Re-install prod container packages, but with cleanup

Andrew Swistak 6 år sedan
förälder
incheckning
70aedc089d
1 ändrade filer med 5 tillägg och 8 borttagningar
  1. 5 8
      Dockerfile

+ 5 - 8
Dockerfile

@@ -45,18 +45,15 @@ COPY --from=builder /app/ /app/
 COPY --from=builder /var/cache/app/ /app/
 
 ################################################################################
-# We want a tiny image, so don't start from base
-FROM ruby:2.6.3-alpine AS prod
+FROM base AS prod
 
 ENV RAILS_ENV=production
-RUN apk add --update --no-cache $RUBY_PACKAGES
 
-RUN mkdir /app
-WORKDIR /app
+# Install only required gems for production, and remove any uneccesary build
+# packages
+RUN bundle install --jobs 4 --retry 5 --without development test && \
+      apk rm $BUILD_PACKAGES $DEV_PACKAGES
 
-# (Re)install only dependencies we need for prod instead of copying everything
-# from the builder
-COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
 # Grab the app with all compiled assets and docker configuration from builder
 COPY --from=builder /app/ /app/