Skip to content

ci: fix Docker build context broken by cbomkit-action leftovers - #344

Merged
n1ckl0sk0rtge merged 1 commit into
mainfrom
fix/docker-build-context
Aug 17, 2026
Merged

n1ckl0sk0rtge merged 1 commit into
mainfrom
fix/docker-build-context

Conversation

@n1ckl0sk0rtge

Copy link
Copy Markdown
Contributor

Problem

main has been red since c13e48a (#313, cbomkit-action 2.1.1 → 2.1.2). Every backend run now fails at Build and push:

ERROR: failed to solve: error from sender:
open 3d209dd94f134bfabcf39448cfbe63d5/11064971341617993163: permission denied

Root cause

The action tag doesn't pin an image. Both tags' Dockerfile is FROM …/cbomkit-action:edge — a mutable tag — but v2.1.1 pointed at ghcr.io/pqca/… (old org, frozen since the org rename) while v2.1.2 points at ghcr.io/cbomkit/…:edge (live). The bump therefore swapped a stale 2025 image for today's edge, which includes the Go integration.

Running that image against a scratch workspace reproduces it — it leaves behind:

1fdfa6d97405491b8c15a7c58b22f0a8/
└── 13331845148632077365/          drwx------
    └── sonar-go-to-slang-linux-arm64

The Go scanner unpacks its helper binary via createTempDirectory rooted at the CWD (/github/workspace) rather than java.io.tmpdir. The action is a Docker action running USER 0:0, so on the runner that tree is root-owned and 0700. docker/build-push-action sends context: . as the runner user, walks into it, and dies. The Create CBOM step itself still reports success — it just leaves droppings the next step trips over.

Fix

There was no .dockerignore, so the entire tree (.git, frontend/node_modules, these leftovers) was shipped as build context — while Dockerfile.jvm only reads target/quarkus-app/** and src/main/resources/java/scan/*.jar. This PR whitelists exactly those, and moves the CBOM steps after the image build as defense in depth.

Verified locally against this repo with a simulated leftover directory: only the 2 whitelisted paths enter the context; the 0700 directory, .git and frontend/ are never opened.

Sizeable build speedup as a side effect.

Follow-ups for cbomkit/cbomkit-action (not fixed here)

  • The Go helper should extract under java.io.tmpdir, not CWD.
  • Release tags should pin a digest rather than :edge — right now v2.1.2 means "whatever edge is today", so the action's behaviour changes under a fixed tag.

The cbomkit-action step runs as a root Docker action and unpacks its Go
scanner helper into a 0700 scratch directory inside the workspace, e.g.

  3d209dd94f134bfabcf39448cfbe63d5/11064971341617993163/sonar-go-to-slang-*

docker/build-push-action then sends the whole repository as build context
as the unprivileged runner user, cannot read that directory, and fails:

  ERROR: failed to solve: error from sender: open <dir>: permission denied

Add a .dockerignore that whitelists only what Dockerfile.jvm consumes
(target/quarkus-app and the BouncyCastle scan jars), so unrelated files in
the workspace can never break or bloat the build context, and move the CBOM
steps after the image build so that step cannot pollute the context at all.

Signed-off-by: Nicklas Körtge <[email protected]>
@n1ckl0sk0rtge
n1ckl0sk0rtge requested a review from a team as a code owner August 17, 2026 07:54
@n1ckl0sk0rtge
n1ckl0sk0rtge merged commit 3c56614 into main Aug 17, 2026
3 checks passed
@n1ckl0sk0rtge
n1ckl0sk0rtge deleted the fix/docker-build-context branch August 17, 2026 08:00
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.

1 participant