diff --git a/Dockerfile b/Dockerfile index 5b4def2..6ae4d7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,23 +2,24 @@ # We use the latest Go 1.x version unless asked to use something else. ARG GO_VERSION=1 +ARG TARGETOS +ARG TARGETARCH # Setup the base environment. -FROM golang:${GO_VERSION} AS base +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS base WORKDIR /fn ENV CGO_ENABLED=0 COPY go.mod go.sum ./ -RUN --mount=type=cache,target=/go/pkg/mod \ - go mod download +RUN --mount=type=cache,target=/go/pkg/mod go mod download # Build the Function. FROM base AS build RUN --mount=target=. \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - go build -o /function . + GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /function . # Produce the Function image. FROM gcr.io/distroless/base-debian11 AS image