Repository navigation
fix(docker): drop gem test folders and lock files from the image - #2058
Conversation
In the same RUN as bundle install, remove the gem cache, git-gem .git folders, top-level spec/test/example folders, and every Gemfile.lock inside installed gems and Ruby's bundled gems. Amazon Inspector reads those lock files as installed packages, so they show up as findings the app never loads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Heads-up on the failing
Dependabot's #2057 already bumps |
|
@JasonBennett41 @frett Friendly nudge on this one. It's updated from master and all checks pass now, |
|
@cru-Luis-Rodriguez taking a look now 👍🏽 |
Resolve the Dockerfile conflict with #2059: keep its BuildKit secret mount and /root/.bundle removal, then run the gem cleanup in the same RUN.
|
I see you added the "On Staging" label, I'll get this merged to the staging branch! |
|
Merge conflict attempting to merge this into staging. Please fix manually. |
|
I see you added the "On Staging" label, I'll get this merged to the staging branch! |
|
Merge conflict attempting to merge this into staging. Please fix manually. |
|
Tested on stage after merging into
|
This drops the test folders and
Gemfile.lockfiles that installed gems ship inside the image. Amazon Inspector reads those lock files as installed packages, so they show up as findings even though the app never loads them. Only theDockerfilechanges.Why
The newest production image (
production-11386) has 19 CRITICAL and 111 HIGH findings in Amazon Inspector. 16 CRITICAL and 90 HIGH of them come from files this change removes, mostly lock files and test folders insiderspec_api_documentation,bundler-auditandraddocs. What stays (3 CRITICAL, 21 HIGH) is mostly thruster's Go binary, which waits on an upstream release. This is part of the DevOps cleanup of Inspector findings across our ECR images.What changes
In the same
RUNasbundle install, so the gem layer itself gets smaller, the build now removes:.gitfolders of git-sourced gemsspec,testandexamplefolders of installed gemsGemfile.lockinside installed gems and inside Ruby's bundled gemsThe app's own
Gemfile.lockis untouched.The same block has run in production since Nov 6 on global_registry (https://github.com/CruGlobal/global_registry/pull/423) and ararat (https://github.com/CruGlobal/ararat/pull/247), and a variant of it on fl-pos-admin (https://github.com/CruGlobal/fl-pos-admin/pull/114).
What I checked
bundle installneeds the Sidekiq Pro login, which only CI has. global_registry and fl-pos-admin also install Sidekiq Pro, and they have run this same cleanup in production since Nov 6. Six other apps in this batch were built locally with it, and all of them passed the checks.Gemfile.lock(the installed copies, the published gem files, and git gems at their locked commits), looking for any that load files from the removed folders or read their own lock files at runtime. It found none.Testing
Jason and Daniel, could you test this on stage before it merges? Merging this branch into
stagingbuilds it and deploys it there. Nothing has built this image yet, so please let that build finish before merging. A quick check that the app loads, sign-in works, and Sidekiq picks up jobs should cover it. Merging tomasterbuilds and deploys to production, and rollback is redeployingproduction-11386from cru-deploy.🤖 Generated with Claude Code