-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
40 lines (29 loc) · 1.02 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
# Build phase
FROM golang:1.23.0-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 main.go main.go
COPY apis/ apis/
COPY internal/ internal/
# Build
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -o /bin/manager main.go && \
strip /bin/manager
# Deployment environment
# ----------------------
FROM golang:1.23.0-alpine3.20
ENV GOCACHE='/tmp/.cache'
RUN mkdir -p "$GOCACHE/go-build" && chmod -R 1777 "$GOCACHE"
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /bin/manager /bin/manager
ENTRYPOINT ["/bin/manager"]