-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
41 lines (30 loc) · 1.06 KB
/
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
33
34
35
36
37
38
39
40
41
# Build environment
# -----------------
FROM golang:1.23-bullseye as builder
LABEL stage=builder
ARG DEBIAN_FRONTEND=noninteractive
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y ca-certificates openssl git tzdata && \
update-ca-certificates && \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY go.mod go.mod
COPY go.sum go.sum
# 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
RUN go mod download
# COPY apis/ apis/
COPY internal/ internal/
COPY main.go main.go
# Build
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -o /bin/controller ./main.go && \
strip /bin/controller
# Deployment environment
# ----------------------
FROM gcr.io/distroless/static:nonroot
# COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /bin/controller /bin/controller
USER nonroot:nonroot
ENTRYPOINT ["/bin/controller"]