skip to Main Content

I need to build a docker image for arm64 and amd64, and I’ve already used buildx.

But the build process for the two platform is lightly different and I would need to use two different Dockerfiles. How should I do?

The detail: the image use s6-overlay and it has two different tarballs depending on the arch

ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp

ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-aarch64.tar.xz /tmp

2

Answers


  1. Chosen as BEST ANSWER

    solution: https://github.com/just-containers/s6-overlay/issues/512#issuecomment-1421339335

    ARG S6_OVERLAY_VERSION="v3.1.3.0"
    RUN wget "https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz" -O "/tmp/s6-overlay-noarch.tar.xz" && 
        tar -C / -Jxpf "/tmp/s6-overlay-noarch.tar.xz" && 
        rm -f "/tmp/s6-overlay-noarch.tar.xz"
    RUN [ "${TARGETARCH}" == "arm64" ] && FILE="s6-overlay-aarch64.tar.xz" || FILE="s6-overlay-x86_64.tar.xz"; 
        wget "https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/${FILE}" -O "/tmp/${FILE}" && 
        tar -C / -Jxpf "/tmp/${FILE}" && 
        rm -f "/tmp/${FILE}"
    

  2. You probably want to create an image that the two dockerfiles can share and do a multi-stage build process. See here in the docker docs

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search