@@ -8,10 +8,11 @@ FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
88WORKDIR /rails
99
1010# Set production environment
11- ENV RAILS_ENV="production" \
12- BUNDLE_DEPLOYMENT="1" \
13- BUNDLE_PATH="/usr/local/bundle" \
14- BUNDLE_WITHOUT="development"
11+ ENV RAILS_ENV="development" \
12+ RAILS_LOG_TO_STDOUT="true" \
13+ RAILS_SERVE_STATIC_FILES="true" \
14+ RAILS_MAX_THREADS="5" \
15+ RAILS_MASTER_KEY=""
1516
1617# Throw-away build stage to reduce size of final image
1718FROM base as build
@@ -22,14 +23,20 @@ RUN apt-get update -qq && \
2223
2324# Install application gems
2425COPY Gemfile Gemfile.lock ./
25- RUN bundle install
26+ RUN bundle install && \
27+ rm -rf ~/.bundle/ "${BUNDLE_PATH}" /ruby/*/cache "${BUNDLE_PATH}" /ruby/*/bundler/gems/*/.git && \
28+ bundle exec bootsnap precompile --gemfile
2629
2730# Copy application code
2831COPY . .
2932
3033# Precompile bootsnap code for faster boot times
3134RUN bundle exec bootsnap precompile app/ lib/
3235
36+ # Precompiling assets for production without requiring secret RAILS_MASTER_KEY
37+ RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
38+
39+
3340# Final stage for app image
3441FROM base
3542
@@ -52,4 +59,4 @@ ENTRYPOINT ["/rails/bin/docker-entrypoint"]
5259
5360# Start the server by default, this can be overwritten at runtime
5461EXPOSE 3000
55- CMD ["./bin/rails" , "server" , "--trace" ]
62+ CMD ["./bin/rails" , "server" ]
0 commit comments