generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile.in
47 lines (33 loc) · 1.37 KB
/
Dockerfile.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#
# BUILDER
#
FROM docker.io/library/golang:1.22 AS builder
WORKDIR /buildroot
# 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.
COPY client/ client/
COPY proto/ proto/
COPY internal/ internal/
COPY {{COMPONENT}}/go.mod {{COMPONENT}}/go.mod
COPY {{COMPONENT}}/go.sum {{COMPONENT}}/go.sum
RUN cd {{COMPONENT}} && go mod download
COPY {{COMPONENT}}/cmd/ {{COMPONENT}}/cmd/
COPY {{COMPONENT}}/pkg/ {{COMPONENT}}/pkg/
WORKDIR /buildroot/{{COMPONENT}}
RUN CGO_ENABLED=0 go build -o /buildroot/artifacts/{{COMPONENT}} cmd/*.go
#
# FINAL IMAGE
#
# gcr.io is deprecated, but gcr.io/distroless/static is hosted by artifact hub with the gcr.io path.
# See: https://github.com/GoogleContainerTools/distroless/issues/1320
FROM gcr.io/distroless/static:nonroot
LABEL maintainers="Kubernetes Authors"
LABEL description="COSI {{COMPONENT}}"
LABEL org.opencontainers.image.title="COSI {{COMPONENT}}"
LABEL org.opencontainers.image.description="Container Object Storage Interface (COSI) {{COMPONENT}}"
LABEL org.opencontainers.image.source="https://github.com/kubernetes-sigs/container-object-storage-interface-api/{{COMPONENT}}"
LABEL org.opencontainers.image.licenses="APACHE-2.0"
WORKDIR /
COPY --from=builder /buildroot/artifacts/{{COMPONENT}} .
USER 65532:65532
ENTRYPOINT ["/{{COMPONENT}}"]