-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
35 lines (24 loc) · 840 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
33
34
35
FROM golang:1.23.1-alpine AS builder
ARG UPX_VERSION=4.2.4-r0
RUN apk update && apk add --no-cache ca-certificates upx=$UPX_VERSION tzdata && update-ca-certificates
WORKDIR /app
COPY go.mod go.sum /app/
RUN go mod download
RUN adduser \
--disabled-password \
--gecos "" \
--home "/" \
--shell "/sbin/nologin" \
--no-create-home \
--uid 64000 \
dnsupdater
COPY . .
RUN go build -buildvcs=false -tags netgo -trimpath -tags netgo -ldflags="-w -s" -o ./dnsupdater cmd/main.go
RUN upx --best --lzma dnsupdater
FROM scratch
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder --chown=dnsupdater:dnsupdater /app/dnsupdater /app/dnsupdater
USER dnsupdater:dnsupdater
ENTRYPOINT ["/app/dnsupdater"]