79381978

Date: 2025-01-23 17:13:53
Score: 0.5
Natty:
Report link

It turns out that this can be solved by using the TARGETARCH variable in my Dockerfile.

So instead of:

RUN set -eux; \
  case "$(uname -m)" in \
    aarch64) ARCH="arm64";; \
    armv7l)  ARCH="arm";;\
    riscv64) ARCH="riscv64";;\
    x86_64)  ARCH="x64";;\
  esac; \

I can use:

ARG TARGETARCH
RUN set -eux; \
  case "${TARGETARCH}" in \
    amd64) ARCH="x64";;\
    *) ARCH=${TARGETARCH};; \
  esac; \

and the ARCH variable then gets set correctly to arm.

With thanks to Bret Fisher and his multi-platform-docker-build repo for showing the way (sadly one of those things where I'd seen this before, but not fully learned to do things the 'right' way going forward).

Reasons:
  • Blacklisted phrase (0.5): thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Chris Swan