Skip to content

fix(express): fix sfw flake and reduce Docker build context#9040

Merged
gokulhost merged 2 commits into
masterfrom
gokuldevaraju330/wcn-972-docker-build-fix-sfw-flake-build-context-optimizations
Jun 16, 2026
Merged

fix(express): fix sfw flake and reduce Docker build context#9040
gokulhost merged 2 commits into
masterfrom
gokuldevaraju330/wcn-972-docker-build-fix-sfw-flake-build-context-optimizations

Conversation

@gokulhost

@gokulhost gokulhost commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Three small changes to harden and speed up the Express Docker build.

Changes

1. Dockerfile — pin sfw and pre-cache its binary

- RUN npm i -g sfw
+ RUN npm i -g --no-fund sfw@2.0.6 && sfw true

npm i -g sfw only installs a JS wrapper; the native firewall binary is fetched lazily on first invocation. Because the first call to sfw is on line 23 (after COPY, invalidated on every yarn.lock change), the binary was re-downloaded from GitHub releases on every hot build. A transient network hiccup in the BuildKit worker → hard CI failure.

sfw true immediately after install forces the binary download into this cached layer, so subsequent builds never re-fetch it. Pinning to 2.0.6 (current latest stable, no known vulnerabilities) prevents a new release from silently busting the cache.

2. .dockerignore — exclude .git

+ .git

.git was not excluded, so the entire 222 MB git history was sent to the BuildKit daemon on every build. No Dockerfile step needs it — GIT_HASH/VERSION are passed in as build args externally.

3. .github/renovate.json — track sfw version automatically

"customManagers": [{
  "customType": "regex",
  "fileMatch": ["(^|/)Dockerfile$"],
  "matchStrings": ["sfw@(?<currentValue>[\\d.]+)"],
  "depNameTemplate": "sfw",
  "datasourceTemplate": "npm"
}]

Renovate will now open a PR automatically when a new sfw version is published to npm, keeping the pin from going stale.

Test plan

  • Docker build completes successfully on CI
  • Confirm the .git exclusion doesn't affect the build (GIT_HASH is injected externally, not read from inside the container)

Closes WCN-972

🤖 Generated with Claude Code

@gokulhost gokulhost requested review from a team as code owners June 16, 2026 20:00
@linear-code

linear-code Bot commented Jun 16, 2026

Copy link
Copy Markdown

WCN-972

WCN-974

gokulhost and others added 2 commits June 16, 2026 13:16
- Pin sfw to 2.0.6 and invoke immediately after install so the native
  firewall binary is cached in the immutable layer rather than
  re-downloaded on every dependency change (fixes intermittent CI flake)
- Add .git to .dockerignore to stop shipping ~222MB of git history in
  the build context on every build

Fixes WCN-972

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a custom regex manager so Renovate opens a PR automatically
whenever a new sfw version is published to npm.

Ref: WCN-972

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gokulhost gokulhost force-pushed the gokuldevaraju330/wcn-972-docker-build-fix-sfw-flake-build-context-optimizations branch from d3eb748 to 09dbc1b Compare June 16, 2026 20:16
@gokulhost gokulhost merged commit 1cf0be6 into master Jun 16, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants