# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Define a default value so it's not empty if the builder fails to provide it ARG BUILDPLATFORM=linux/amd64 FROM --platform=$BUILDPLATFORM golang:1.26.4-alpine@sha256:3ad57304ad93bbec8548a0437ad9e06a455660655d9af011d58b993f6f615648 AS builder ARG TARGETOS=linux ARG TARGETARCH=amd64 WORKDIR /src # restore dependencies COPY go.mod go.sum ./ RUN go mod download COPY . . # Skaffold passes in debug-oriented compiler flags ARG SKAFFOLD_GO_GCFLAGS RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -ldflags="-s -w" -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o /checkoutservice . FROM gcr.io/distroless/static WORKDIR /src COPY --from=builder /checkoutservice /src/checkoutservice # Definition of this variable is used by 'skaffold debug' to identify a golang binary. # Default behavior - a failure prints a stack trace for the current goroutine. # See https://golang.org/pkg/runtime/ ENV GOTRACEBACK=single EXPOSE 5050 ENTRYPOINT ["/src/checkoutservice"]