From 2e2205d938ba70e573a4bc1269e60af57a9347ab Mon Sep 17 00:00:00 2001 From: Pieter Hollander Date: Sat, 10 Aug 2024 23:44:45 +0200 Subject: [PATCH] Add ARG TARGETOS TARGETARCH to fix multi-platform builds. --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 0746151..064c362 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,9 @@ RUN go mod download COPY . . # Build the application for the specified target architecture +# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/ +# Declare TARGETOS and TARGETARCH in the local scope so they can be used in the build stage. +ARG TARGETOS TARGETARCH RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o p1-logger . # Create a minimal runtime image