github.com/oam-dev/kubevela@v1.9.11/Dockerfile.cli (about) 1 ARG BASE_IMAGE 2 # Build the cli binary 3 FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19-alpine@sha256:2381c1e5f8350a901597d633b2e517775eeac7a6682be39225a93b22cfd0f8bb as builder 4 ARG GOPROXY 5 ENV GOPROXY=${GOPROXY:-https://proxy.golang.org} 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 apis/ apis/ 16 COPY pkg/ pkg/ 17 COPY version/ version/ 18 COPY references/ references/ 19 20 # Build 21 ARG TARGETARCH 22 ARG VERSION 23 ARG GITVERSION 24 25 RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH:-amd64} \ 26 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}" \ 27 -o vela-${TARGETARCH} ./references/cmd/cli/main.go 28 29 30 # Use alpine as base image due to the discussion in issue #1448 31 # You can replace distroless as minimal base image to package the manager binary 32 # Refer to https://github.com/GoogleContainerTools/distroless for more details 33 # Overwrite `BASE_IMAGE` by passing `--build-arg=BASE_IMAGE=gcr.io/distroless/static:nonroot` 34 35 FROM ${BASE_IMAGE:-alpine:3.15@sha256:cf34c62ee8eb3fe8aa24c1fab45d7e9d12768d945c3f5a6fd6a63d901e898479} 36 # This is required by daemon connecting with cri 37 RUN apk add --no-cache ca-certificates bash expat 38 39 WORKDIR / 40 41 ARG TARGETARCH 42 COPY --from=builder /workspace/vela-${TARGETARCH} /bin/vela 43 ENTRYPOINT ["/bin/vela"]