-
Couldn't load subscription status.
- Fork 2
Description
When I build a Docker container using docker/build-push-action with provenance: mode=max and sbom: true it creates a multi-arch manifest that really is just single-arch + provenance, targeting arm64 (aarch64):
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:ff90c4b1a4c0d4299919d8c0bb9260ffedd3506836cb12c87935215eb305d78c",
"size": 6169,
"platform": {
"architecture": "arm64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:23e95dc47ff87c2068c3ebcf5d1d0510a1781b4d6b58126a4cdcdd105864ce23",
"size": 842,
"annotations": {
"vnd.docker.reference.digest": "sha256:ff90c4b1a4c0d4299919d8c0bb9260ffedd3506836cb12c87935215eb305d78c",
"vnd.docker.reference.type": "attestation-manifest"
},
"platform": {
"architecture": "unknown",
"os": "unknown"
}
}
]
}If I then have a Dockerfile that has a FROM that references an ARG pointing to the manifest:
ARG DTAG
FROM ${DTAG}
and a docker-compose.yml with:
version: '2.4'
services:
myimage:
build:
context: .
dockerfile: ./Dockerfile
args:
DTAG: '{{ .DTAG }}'This works fine for docker-compose build --build-arg DTAG=myregistry.com/myimage:sha-2e991d20-arm64, but if I try to use balena deploy myaarch64fleet --debug, with a .balena/balena.yml file that has:
build-variables:
global:
- DTAG=myregistry.com/myimage:sha-2e991d20-arm64I get:
[Debug] Parsing input...
[Debug] Loading project...
[Debug] Resolving project...
[Debug] docker-compose.yml file found at "/home/runner/work/test/balena"
[Debug] Creating project...
[Build] Building services...
[Build] myimage Preparing...
[Info] Building for aarch64/generic-aarch64
[Debug] Found build tasks:
[Debug] myimage: build [.]
[Debug] Resolving services with [generic-aarch64|aarch64]
[Debug] Found project types:
[Debug] myimage: Standard Dockerfile
[Debug] Prepared tasks; building...
[Debug] myimage: Image manifest data unavailable for ${DTAG}
[Build] Built 1 services in 0:00
Error: Deploy failed
no matching manifest for linux/amd64 in the manifest list entries
Error: no matching manifest for linux/amd64 in the manifest list entries
at Stream.<anonymous> (/snapshot/balena-cli/node_modules/@balena/compose/dist/build/builder.js:107:23)
at Stream.write (/snapshot/balena-cli/node_modules/through/index.js:26:11)
at Stream.ondata (node:internal/streams/legacy:20:31)
at Stream.emit (node:events:537:28)
at drain (/snapshot/balena-cli/node_modules/through/index.js:36:16)
at Stream.<anonymous> (/snapshot/balena-cli/node_modules/through/index.js:45:5)
at Parser.onToken (/snapshot/balena-cli/node_modules/JSONStream/index.js:132:18)
at Parser.write (/snapshot/balena-cli/node_modules/jsonparse/jsonparse.js:135:34)
at Stream.<anonymous> (/snapshot/balena-cli/node_modules/JSONStream/index.js:23:12)
at Stream.write (/snapshot/balena-cli/node_modules/through/index.js:26:11)
at IncomingMessage.ondata (node:internal/streams/readable:766:22)
at IncomingMessage.emit (node:events:537:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at HTTPParser.parserOnBody (node:_http_common:130:24)
So, first off, this all works fine if Provenance/SBOM is disabled. Next, I'm sure you're wondering why use an ARG for the FROM. We do this because we generate a multi-arch docker image for use in a bunch of places, and when we use it on Balena, we point to just one architecture to keep Balena happy.
With no provenance/SBOM, that is a "mediaType": "application/vnd.docker.distribution.manifest.v2+json", but with provenance/SBOM it is a "mediaType": "application/vnd.oci.image.index.v1+json". #22 seems like it fixed this, but something is still off.
In the above error, I am targeting a linux/arm64 platform but running the build on a linux/amd64 platform... and it is failing to find the amd64 manifest. If I target a linux/amd64 on the linux/amd64 builder it works fine.
Additionally, the [Debug] myimage: Image manifest data unavailable for ${DTAG} appears that ARG parsing needs to happen before walking the docker-compose services.
I'm still digging, but I figured 6 hours in I would get a ticket started...