-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathDockerfile
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:7ea4c9dcb2b97ff8ee80a67db3d44f98c8ffa0d191399197007d8459c1453041 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:6cd937e9155bdfd805d1b94e037f9d6a899603306030936a3b11680af0c2ed58
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