content: # syntax=docker/dockerfile:1
  # Build the manager binary
  FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.25.1@sha256:e05ea9c54d7e519c40fdebbf1a7bb60dbe9b8cf5210073d4c1c13b4f74aa4724 AS builder 
  WORKDIR /workspace
  # Copy the Go Modules manifests
  COPY go.mod go.mod
  COPY go.sum go.sum
  # cache deps before building and copying source so that we don't need to re-download as much
  # and so that source changes don't invalidate our downloaded layer
  RUN go mod download
  # Copy the go source
  COPY cmd/ cmd/
  COPY api/ api/
  COPY controllers/ controllers/
  COPY pkg/ pkg/
  
  ARG MAIN_ENTRY
  ARG TARGETARCH
  FROM builder AS base
  WORKDIR /workspace
  # Build
  RUN GOEXPERIMENT=nosystemcrypto CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -a -o ${MAIN_ENTRY}  ./cmd/${MAIN_ENTRY}/main.go
  
  # Use distroless as minimal base image to package the manager binary
  # Refer to https://github.com/GoogleContainerTools/distroless for more details
  FROM gcr.io/distroless/static:nonroot@sha256:c0f429e16b13e583da7e5a6ec20dd656d325d88e6819cafe0adb0828976529dc
  ARG MAIN_ENTRY
  WORKDIR /
  COPY --from=base /workspace/${MAIN_ENTRY} .
  USER 65532:65532
  
  ENTRYPOINT ["${MAIN_ENTRY}"]
  
  
  