github.com/oam-dev/kubevela@v1.9.11/Dockerfile (about)

     1  ARG BASE_IMAGE
     2  # Build the manager binary
     3  FROM golang:1.19-alpine3.18 as builder
     4  
     5  WORKDIR /workspace
     6  # Copy the Go Modules manifests
     7  COPY go.mod go.mod
     8  COPY go.sum go.sum
     9  
    10  # It's a proxy for CN developer, please unblock it if you have network issue
    11  ARG GOPROXY
    12  ENV GOPROXY=${GOPROXY:-https://proxy.golang.org}
    13  
    14  # cache deps before building and copying source so that we don't need to re-download as much
    15  # and so that source changes don't invalidate our downloaded layer
    16  RUN go mod download
    17  
    18  # Copy the go source for building core
    19  COPY cmd/core/ cmd/core/
    20  COPY apis/ apis/
    21  COPY pkg/ pkg/
    22  COPY version/ version/
    23  COPY references/ references/
    24  
    25  # Build
    26  ARG TARGETARCH
    27  ARG VERSION
    28  ARG GITVERSION
    29  RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} \
    30      go build -a -ldflags "-s -w -X github.com/oam-dev/kubevela/version.VelaVersion=${VERSION:-undefined} -X github.com/oam-dev/kubevela/version.GitRevision=${GITVERSION:-undefined}" \
    31      -o manager-${TARGETARCH} cmd/core/main.go
    32  
    33  # Use alpine as base image due to the discussion in issue #1448
    34  # You can replace distroless as minimal base image to package the manager binary
    35  # Refer to https://github.com/GoogleContainerTools/distroless for more details
    36  # Overwrite `BASE_IMAGE` by passing `--build-arg=BASE_IMAGE=gcr.io/distroless/static:nonroot`
    37  FROM ${BASE_IMAGE:-alpine:3.18}
    38  # This is required by daemon connecting with cri
    39  RUN apk add --no-cache ca-certificates bash expat
    40  
    41  WORKDIR /
    42  
    43  ARG TARGETARCH
    44  COPY --from=builder /workspace/manager-${TARGETARCH} /usr/local/bin/manager
    45  
    46  COPY entrypoint.sh /usr/local/bin/
    47  
    48  ENTRYPOINT ["entrypoint.sh"]
    49  
    50  CMD ["manager"]