Skip to content

Commit eb70a45

Browse files
committed
chore: Refactor Dockerfile for gem installation and precompilation
1 parent 1650cf9 commit eb70a45

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

Dockerfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
88
WORKDIR /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
1718
FROM base as build
@@ -22,14 +23,20 @@ RUN apt-get update -qq && \
2223

2324
# Install application gems
2425
COPY 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
2831
COPY . .
2932

3033
# Precompile bootsnap code for faster boot times
3134
RUN 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
3441
FROM base
3542

@@ -52,4 +59,4 @@ ENTRYPOINT ["/rails/bin/docker-entrypoint"]
5259

5360
# Start the server by default, this can be overwritten at runtime
5461
EXPOSE 3000
55-
CMD ["./bin/rails", "server", "--trace"]
62+
CMD ["./bin/rails", "server"]

config/couchbase.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ development:
1010
test:
1111
<<: *common
1212
bucket: travel-sample
13+
14+
production:
15+
<<: *common
16+
bucket: travel-sample

0 commit comments

Comments
 (0)