-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
32 lines (23 loc) · 904 Bytes
/
Dockerfile
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
FROM golang:1.23@sha256:73f06be4578c9987ce560087e2e2ea6485fb605e3910542cadd8fa09fc5f3e31 AS build
WORKDIR /workspace
ENV GO111MODULE=on
COPY *.go go.mod *.sum ./
# Download
RUN go mod download
# Bulild
COPY cmd ./cmd
COPY internal ./internal
RUN CGO_ENABLED=0 go build -o app -ldflags '-w -extldflags "-static"' ./cmd
#Test
RUN CCGO_ENABLED=0 go test -v ./...
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
# debug tag adds a shell (not recommended for prod)
FROM gcr.io/distroless/static:nonroot@sha256:d71f4b239be2d412017b798a0a401c44c3049a3ca454838473a4c32ed076bfea
WORKDIR /
COPY --from=build /workspace/app /app/app
USER nonroot:nonroot
ENTRYPOINT ["/app/app"]
ARG IMAGE_SOURCE
#https://github.com/k8s-at-home/template-container-image
LABEL org.opencontainers.image.source $IMAGE_SOURCE