Fdops 5471 - Docker Image Dependency Pre-Caching#7425
Merged
Conversation
hjiebsco
approved these changes
Jul 14, 2026
…into FDOPS-5471
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Docker Image Dependency Pre-Caching
Summary
Reworked
DockerfileCypressandDockerfileCypressAmdso that project dependencies (yarn packages + the Cypress binary) are downloaded once at image build time and baked into the image, instead of being downloaded on every Jenkins job run.What was changed
DockerfileCypressandDockerfileCypressAmdYARN_CACHE_FOLDER=/opt/yarn-cacheCYPRESS_CACHE_FOLDER=/opt/cypress-cacheCOPY package.json yarn.lock ./before install so the layer cache is invalidated only when deps actually change.RUN yarn install --frozen-lockfilepopulates the yarn cache with every tarball the project needs and triggers Cypress's postinstall.RUN npx cypress install(safety net) guarantees the Cypress 12 binary lands in/opt/cypress-cache.rm -rf node_modulesright after — the caches are what we want to keep, the extractednode_modulesis rebuilt in the Jenkins workspace at runtime.chmod -R a+rwX /opt/yarn-cache /opt/cypress-cache /opt/appso the non-root user that Jenkins runs the container as can read/write the cachesnpm install --save-dev cypressline — Cypress is already installed viayarn installfrom the lockfile.New
.dockerignoreTrims the build context sent to the Docker daemon (excludes
node_modules,.git, Cypress screenshots/videos, allure reports, IDE folders, logs, local env files, etc.). Speeds up builds; doesn't affect image contents since we onlyCOPYpackage.jsonandyarn.lock.How It Works Now
Image build (one-time per lockfile change):
/opt/yarn-cache./opt/cypress-cache.FSE Jenkins runtime (every job run):
YARN_CACHE_FOLDERandCYPRESS_CACHE_FOLDERenv vars already pointing at the baked-in caches.yarn installin the workspace hits the local cache — no network fetches of package tarballs./opt/cypress-cache— no binary download.Tradeoffs
package.json/yarn.lockchangeThe image size increase is intentional: we shifted the download cost from every Jenkins run into image storage. The one-time layer pull is amortized across all subsequent job runs.