Replies: 2 comments 3 replies
-
Use the FROM --platform ${BUILDPLATFORM} golang AS builder
# now you could do cross-compilation without qemu and the architecture will following host
ARG TARGETARCH
RUN GOARCH=${TARGETARCH} go build -o /bin/app ./cmd/app
FROM scrach
# the stage need qemu to make builder support to differect platform from platform of host .
# if some RUN here need qemu too
COPY --from=builder /bin/app /bin/app
Yes. you could split to multiple stages for per arch FROM image-for-amd64 AS builder-amd64
FROM image-for-arm64 AS builder-arm64
FROM builder-${TARGETARCH} |
Beta Was this translation helpful? Give feedback.
0 replies
-
More advanced cross-compilation cases are described in https://github.com/tonistiigi/xx#dockerfile-cross-compilation-primer . |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The README states that I can
use a stage in Dockerfile to cross-compile to different architectures.
, however I can't find any examples of doing this - everything either uses SSH to another machine or qemu. I have already put work into cross-compiling various software, I'd rather just be able to do that without adding more moving parts.Are there any examples of doing this? Can I select a different image per arch, or do I need to have a single image with multiple cross compilers, then use the BUILDARCH variable or something?
Beta Was this translation helpful? Give feedback.
All reactions