fix(docker): build custom OPA from ./cmd/opa when present (permit-opa per-12529 layout) - #324
Conversation
permit-opa's per-12529 branch moves its main package from the repo root to ./cmd/opa (cmd/ + pkg/ layout). The bare 'go build' here compiles the package in the tarball root, so once that branch merges to permit-opa main, the custom OPA stage fails with 'no Go files'. Detect the layout and build whichever main-package location the tarball provides — the stage now works against permit-opa main both before and after that merge. Verified by building the opa_build stage with tarballs generated (via the release workflow's find command) from both layouts; both produce a working static OPA binary. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🔍 Vulnerabilities of
|
| digest | sha256:12d1fb1158738529efbd927cbef9e0642dc214b11679ea018df2ce929fb48588 |
| vulnerabilities | |
| platform | linux/amd64 |
| size | 225 MB |
| packages | 264 |
📦 Base Image python:3.10-alpine3.22
| also known as |
|
| digest | sha256:c8f94b3bb77e6ea9015ccd091b7f8aec1b1fcbca95159675235d9a93788797cd |
| vulnerabilities |
Description
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
|
|
CI status note: The two failing checks are unrelated to the Dockerfile change:
|
Why
permit-opa's
per-12529branch (permit-opa PR #33) moves its main package from the repo root to./cmd/opa(standardcmd/+pkg/layout). Theopa_buildstage here runs a barego build, which compiles the package in the tarball root — once that branch merges to permit-opamain, the release/tests builds (which check out permit-opamainand tar its Go sources intocustom_opa.tar.gz) fail withno Go files in /custom.The tarball-creation side (
release.yml,tests.yml,build_opal_bundle.sh) needs no change: its recursivefindalready picks up the sources undercmd/andpkg/with paths intact.What
Detect the layout inside the extracted tarball and build whichever main-package location it provides:
cmd/opaexists →go build ./cmd/opa(new layout)go build .(current root layout)This makes the stage work against permit-opa
mainboth before and after the per-12529 merge, so merge ordering can't break a release.Verification
Built the
opa_buildstage locally withcustom_opa.tar.gzgenerated by the release workflow's exactfindcommand from both permit-opa layouts:cmd/+pkg/): ✅ builds,/opa version→ 1.14.1, binary contains the newpkg/plugin/query_enginepackagesmain(root layout): ✅ builds,/opa version→ 1.14.1Merge plan
Draft until permit-opa per-12529 merges to main. (The conditional makes it safe to merge earlier if convenient, but keeping the ordering explicit.)
🤖 Generated with Claude Code