Skip to content

Commit

Permalink
Merge pull request #1 from vlsi/fix_go_build_arch
Browse files Browse the repository at this point in the history
chore: use proper GOOS and GOARCH for go build rather than static linux/amd64
  • Loading branch information
mrMigles authored Jan 22, 2025
2 parents e04b2b9 + fb24eb5 commit 0cd9c25
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Build the manager binary
FROM golang:1.22.5-alpine3.20 as builder
# Note: this uses host platform for the build, and we ask go build to target the needed platform, so we do not spend time on qemu emulation when running "go build"
FROM --platform=$BUILDPLATFORM golang:1.22.5-alpine3.20 as builder
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

ENV GOSUMDB=off

Expand All @@ -26,7 +30,7 @@ COPY utils/ utils/
# Tests
RUN CGO_ENABLED=0 go test -v ./...
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager cmd/main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on go build -a -o manager cmd/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down

0 comments on commit 0cd9c25

Please sign in to comment.