Skip to content

Fdops 5471 - Docker Image Dependency Pre-Caching#7425

Merged
kbrener-eis merged 3 commits into
masterfrom
FDOPS-5471
Jul 14, 2026
Merged

Fdops 5471 - Docker Image Dependency Pre-Caching#7425
kbrener-eis merged 3 commits into
masterfrom
FDOPS-5471

Conversation

@kbrener-eis

Copy link
Copy Markdown
Contributor

Docker Image Dependency Pre-Caching

Summary

Reworked DockerfileCypress and DockerfileCypressAmd so 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

DockerfileCypress and DockerfileCypressAmd

  • Added two persistent cache paths via env vars:
    • YARN_CACHE_FOLDER=/opt/yarn-cache
    • CYPRESS_CACHE_FOLDER=/opt/cypress-cache
  • COPY package.json yarn.lock ./ before install so the layer cache is invalidated only when deps actually change.
  • RUN yarn install --frozen-lockfile populates 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_modules right after — the caches are what we want to keep, the extracted node_modules is rebuilt in the Jenkins workspace at runtime.
  • chmod -R a+rwX /opt/yarn-cache /opt/cypress-cache /opt/app so the non-root user that Jenkins runs the container as can read/write the caches
  • Dropped the redundant npm install --save-dev cypress line — Cypress is already installed via yarn install from the lockfile.

New .dockerignore

Trims 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 only COPY package.json and yarn.lock.

How It Works Now

  1. Image build (one-time per lockfile change):

    • Yarn downloads every tarball into /opt/yarn-cache.
    • Cypress downloads its binary into /opt/cypress-cache.
    • Both caches are chmod'd world-writable and shipped inside the image.
  2. FSE Jenkins runtime (every job run):

    • Container starts with YARN_CACHE_FOLDER and CYPRESS_CACHE_FOLDER env vars already pointing at the baked-in caches.
    • yarn install in the workspace hits the local cache — no network fetches of package tarballs.
    • Cypress verifies its executable from /opt/cypress-cache — no binary download.
    • Jenkins job should complete the "install" phase in seconds instead of the previous multi-minute download.

Tradeoffs

Aspect Before After
Per-run install time Minutes (full download) Seconds (cache hit)
Image size Baseline ~2× larger (yarn cache + Cypress binary)
Rebuild trigger Never (deps fetched at runtime) On package.json / yarn.lock change
Network at test time Required Not required for deps

The 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.

@kbrener-eis kbrener-eis added the AI label Jul 14, 2026
@kbrener-eis kbrener-eis changed the title Fdops 5471 Fdops 5471 - Docker Image Dependency Pre-Caching Jul 14, 2026
@kbrener-eis kbrener-eis merged commit 2675b30 into master Jul 14, 2026
13 checks passed
@kbrener-eis kbrener-eis deleted the FDOPS-5471 branch July 14, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants