Skip to content

Commit

Permalink
Use the Docker Build Kit platform vars
Browse files Browse the repository at this point in the history
The Docker Build Kit exports the target OS and architecture as build
args so we can use them instead of assuming linux/amd64.

https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope

Signed-off-by: Dave Shawley <[email protected]>
  • Loading branch information
dave-shawley committed Apr 11, 2023
1 parent b9b818d commit 518118a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
FROM golang:1.20 as builder
WORKDIR /workspace

ARG TARGETARCH=amd64
ARG TARGETOS=linux

ENV GOPROXY=direct
# Copy the Go Modules manifests
COPY go.mod go.mod
Expand All @@ -15,8 +18,8 @@ COPY main.go main.go
COPY pkg/ pkg/

ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH
ENV GO111MODULE=on

# Do an initial compilation before setting the version so that there is less to
Expand Down

0 comments on commit 518118a

Please sign in to comment.