Native builder: add the current target platform we're building use it to set automatic platform ARGs
Feature or enhancement request details
We should add the current target platform we're building and use it to set automatic platform ARGs:
// Build platform ARGs.
args["BUILDPLATFORM"] = buildPlatform.description
args["BUILDOS"] = buildPlatform.os
args["BUILDARCH"] = buildPlatform.architecture
args["BUILDVARIANT"] = buildPlatform.variant ?? ""
// Target platform ARGs.
args["TARGETPLATFORM"] = targetPlatform.description
args["TARGETOS"] = targetPlatform.os
args["TARGETARCH"] = targetPlatform.architecture
args["TARGETVARIANT"] = targetPlatform.variant ?? ""
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Not sure what this issue is tracking but I discovered today that these variables are available already in container ["CLI version 0.9.0 (build: release, commit: 3e49dce)"]. However they must be specified via ARG first. E.g.
FROM docker.io/alpine:3
RUN env && exit 1
does not reveal any build info, but
FROM docker.io/alpine:3
ARG TARGETARCH
RUN env && exit 1
Does show the TARGETARCH as being provided. This is consistent with Docker's own behavior as documented in https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope.
Native builder work is not in our near term plan. Closing for now, but may reopen in the future when we're ready to work on native builder again.