containers / common

Location for shared common files in github.com/containers repos.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Containerfile.5.md should document "magic" build-args

cevich opened this issue · comments

Podman and buildah (I believe) both support similar/same set of automatic build-args as in the Docker documentation (I'm guessing, so maybe not all are supported?):

  • TARGETPLATFORM - platform of the build result. Eg linux/amd64, linux/arm/v7, windows/amd64.
  • TARGETOS - OS component of TARGETPLATFORM
  • TARGETARCH - architecture component of TARGETPLATFORM
  • TARGETVARIANT - variant component of TARGETPLATFORM
  • BUILDPLATFORM - platform of the node performing the build.
  • BUILDOS - OS component of BUILDPLATFORM
  • BUILDARCH - architecture component of BUILDPLATFORM
  • BUILDVARIANT - variant component of BUILDPLATFORM

In either case, some/all of these should be documented in the Containerfile man page. There are many situations where (esp) knowing (for example) the BUILDARCH is useful in RUN commands. Importantly because it's golang-flavored and difficult to access elsewhere (i.e. uname -m is different).

Interested in opening a PR?

I must admit I'm tempted to, I'm simply afraid I may not be able to get to it soon-ish. I'll put it on my TODO list, but if anybody else is inspired to fix this they should go ahead.

Update: Don't bother trying to reference any of these build args in podman or buildah. Tested with podman 4.9.4 and 5.1.1, neither work. Example Containerfile:

FROM registry.fedoraproject.org/fedora-minimal:latest
ENV TARGETPLATFORM=${TARGETPLATFORM} \
    TARGETOS=${TARGETOS} \
    TARGETARCH=${TARGETARCH} \
    TARGETVARIANT=${TARGETVARIANT} \
    BUILDPLATFORM=${BUILDPLATFORM} \
    BUILDOS=${BUILDOS} \
    BUILDARCH=${BUILDARCH} \
    BUILDVARIANT=${BUILDVARIANT}
RUN printenv

Tested with a regular build and a --manifest=XYZ build including multiple platforms.