github.com/oam-dev/cluster-gateway@v1.9.0/cmd/apiserver/Dockerfile (about)

     1  # Build the manager binary
     2  FROM golang:1.20-alpine as builder
     3  ARG OS
     4  ARG ARCH
     5  
     6  WORKDIR /workspace
     7  # Copy the Go Modules manifests
     8  COPY go.mod go.mod
     9  COPY go.sum go.sum
    10  # cache deps before building and copying source so that we don't need to re-download as much
    11  # and so that source changes don't invalidate our downloaded layer
    12  RUN go mod download
    13  
    14  # Copy the go source
    15  COPY cmd/ cmd/
    16  COPY pkg/ pkg/
    17  COPY hack/ hack/
    18  
    19  ARG API_GROUP_NAME=cluster.core.oam.dev
    20  
    21  # Build
    22  RUN CGO_ENABLED=0 \
    23      GOOS=${OS} \
    24      GOARCH=${ARCH} \
    25      go build \
    26          -ldflags="-X 'github.com/oam-dev/cluster-gateway/pkg/config.MetaApiGroupName=${API_GROUP_NAME}'" \
    27          -o apiserver \
    28          cmd/apiserver/main.go
    29  
    30  RUN CGO_ENABLED=0 \
    31      GOOS=${OS} \
    32      GOARCH=${ARCH} \
    33      go build \
    34          -o patch \
    35          hack/patch/main.go
    36  
    37  # Use distroless as minimal base image to package the manager binary
    38  # Refer to https://github.com/GoogleContainerTools/distroless for more details
    39  FROM alpine:3
    40  
    41  WORKDIR /
    42  COPY --from=builder /workspace/apiserver /
    43  COPY --from=builder /workspace/patch /
    44  
    45  ENTRYPOINT ["/apiserver"]