Browse Source

Set GOOS and GOARCH from TARGETPLATFORM (#1915)

Removed hardcoded, single platform values for GOOS and GOARCH.
Set GOOS and GOARCH from TARGETPLATFORM to build multi-platform images.
Ref: https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
Ref: https://docs.docker.com/build/building/multi-platform/
Build a multi-platform image `docker buildx build --push --platform linux/arm64,linux/amd64 --tag external-secrets:dev --file Dockerfile.standalone .`

Signed-off-by: a27kash <a27kash@gmail.com>

Signed-off-by: a27kash <a27kash@gmail.com>
Signed-off-by: Moritz Johner <moolen@users.noreply.github.com>
Co-authored-by: Moritz Johner <moolen@users.noreply.github.com>
a27kash 3 years ago
parent
commit
5ab02775ca
1 changed files with 4 additions and 1 deletions
  1. 4 1
      Dockerfile.standalone

+ 4 - 1
Dockerfile.standalone

@@ -1,6 +1,9 @@
 # This version of Dockerfile is for building without external dependencies.
+# Build a multi-platform image e.g. `docker buildx build --push --platform linux/arm64,linux/amd64 --tag external-secrets:dev --file Dockerfile.standalone .`
 FROM golang:1.19.5-alpine AS builder
-ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
+ARG TARGETOS
+ARG TARGETARCH
+ENV CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH}
 WORKDIR /app
 # Avoid invalidating the `go mod download` cache when only code has changed.
 COPY go.mod go.sum /app/