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

     1  ARG BASE_IMAGE
     2  # Build the manager binary
     3  FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19-alpine@sha256:2381c1e5f8350a901597d633b2e517775eeac7a6682be39225a93b22cfd0f8bb 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  # cache deps before building and copying source so that we don't need to re-download as much
    10  # and so that source changes don't invalidate our downloaded layer
    11  RUN go mod download
    12  
    13  # Copy the go source
    14  COPY cmd/core/main.go main.go
    15  COPY cmd/core/main_e2e_test.go main_e2e_test.go
    16  COPY cmd/ cmd/
    17  COPY apis/ apis/
    18  COPY pkg/ pkg/
    19  COPY version/ version/
    20  COPY references/ references/
    21  
    22  # Build
    23  ARG TARGETARCH
    24  ARG VERSION
    25  ARG GITVERSION
    26  
    27  RUN  apk add gcc musl-dev libc-dev ;\
    28      GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} \
    29      go test -c -o manager-${TARGETARCH}  -cover -covermode=atomic -coverpkg ./... .
    30  
    31  # Use alpine as base image due to the discussion in issue #1448
    32  # You can replace distroless as minimal base image to package the manager binary
    33  # Refer to https://github.com/GoogleContainerTools/distroless for more details
    34  # Overwrite `BASE_IMAGE` by passing `--build-arg=BASE_IMAGE=gcr.io/distroless/static:nonroot`
    35  
    36  FROM ${BASE_IMAGE:-alpine:3.15@sha256:cf34c62ee8eb3fe8aa24c1fab45d7e9d12768d945c3f5a6fd6a63d901e898479}
    37  # This is required by daemon connecting with cri
    38  RUN apk add --no-cache ca-certificates bash expat
    39  
    40  WORKDIR /
    41  
    42  ARG TARGETARCH
    43  COPY --from=builder /workspace/manager-${TARGETARCH} /usr/local/bin/manager
    44  
    45  COPY entrypoint.sh /usr/local/bin/
    46  
    47  VOLUME ["/workspace/data"]
    48  
    49  ENTRYPOINT ["entrypoint.sh"]
    50  
    51  CMD ["manager"]