Dockerfile: Use a cache mount for bundled gems

ref: https://fizzy.37signals.com/5986089/collections/7/cards/1338
This commit is contained in:
Mike Dalessio
2025-08-11 14:00:00 -04:00
parent 278a8f9f96
commit 51ab69a2cf
+2 -3
View File
@@ -24,9 +24,8 @@ RUN apt-get update -qq && \
# Install application gems # Install application gems
COPY Gemfile Gemfile.lock .ruby-version ./ COPY Gemfile Gemfile.lock .ruby-version ./
RUN --mount=type=secret,id=GITHUB_TOKEN \ RUN --mount=type=secret,id=GITHUB_TOKEN --mount=type=cache,id=fizzy-permabundle-${RUBY_VERSION},sharing=locked,target=/permabundle \
gem install bundler &&\ BUNDLE_PATH=/permabundle BUNDLE_GITHUB__COM="$(cat /run/secrets/GITHUB_TOKEN):x-oauth-basic" bundle install && \
BUNDLE_GITHUB__COM="$(cat /run/secrets/GITHUB_TOKEN):x-oauth-basic" bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile bundle exec bootsnap precompile --gemfile