From b310c8df57d66510b318082e8e9ff4a19dfe5787 Mon Sep 17 00:00:00 2001 From: Peter Svensson Date: Mon, 19 Jan 2026 08:31:53 +0100 Subject: [PATCH 1/2] build: support multi-architecture builds in Dockerfile Add ARG directives for TARGETOS and TARGETARCH to enable multi-architecture support. Modify the build command to use the specified target OS and architecture for more flexible and portable builds. Ensure compatibility with different deployment environments. --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f120ed6..cb228f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,9 @@ ADD go.* /build RUN go mod download FROM deps as build +ARG TARGETOS +ARG TARGETARCH + ENV CGO_ENABLED=0 ADD . /build RUN if [ $(go mod tidy -v 2>&1 | grep -c unused) != 0 ]; then echo "Unused modules, please run 'go mod tidy'"; exit 1; fi @@ -14,7 +17,7 @@ RUN ["/bin/bash", "-c", "cat coverage.txt.tmp | grep -v -f <(find . -type f | xa RUN go tool cover -html=coverage.txt -o coverage.html RUN go tool cover -func=coverage.txt RUN rm coverage.txt.tmp -RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -mod=readonly -o release/default-request-adder -ldflags '-w -s' +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -mod=readonly -o release/default-request-adder -ldflags '-w -s' FROM scratch as export COPY --from=build /build/coverage.txt / -- 2.52.0 From 9a089c8af75a45f544c689542a5652400652dfc8 Mon Sep 17 00:00:00 2001 From: Peter Svensson Date: Mon, 19 Jan 2026 08:28:02 +0100 Subject: [PATCH 2/2] fix: standardize Dockerfile stage names to uppercase Updates the Dockerfile to use uppercase for multi-stage build definitions. This change enhances readability and maintains consistency across the build stages, ensuring alignment with common best practices in Dockerfile conventions. --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index cb228f7..7aab3ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM golang:1.25.6@sha256:fc24d3881a021e7b968a4610fc024fba749f98fe5c07d4f28e6cfa14dc65a84c as deps +FROM golang:1.25.6@sha256:fc24d3881a021e7b968a4610fc024fba749f98fe5c07d4f28e6cfa14dc65a84c AS deps WORKDIR /build ADD go.* /build RUN go mod download -FROM deps as build +FROM deps AS build ARG TARGETOS ARG TARGETARCH @@ -19,7 +19,7 @@ RUN go tool cover -func=coverage.txt RUN rm coverage.txt.tmp RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -mod=readonly -o release/default-request-adder -ldflags '-w -s' -FROM scratch as export +FROM scratch AS export COPY --from=build /build/coverage.txt / FROM scratch -- 2.52.0