forked from k8s-gateway/k8s_gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
41 lines (29 loc) · 957 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
36
37
38
39
40
41
FROM --platform=${BUILDPLATFORM} docker.io/library/golang:1.24-alpine AS builder
ARG LDFLAGS
ARG VERSION=dev
ARG REVISION=dev
WORKDIR /build
# Copy the Go Modules manifests
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 cmd/ cmd/
COPY *.go ./
ARG TARGETOS
ARG TARGETARCH
ENV CGO_ENABLED=0 \
GO111MODULE=on \
GOARCH=$TARGETARCH \
GOOS=$TARGETOS
RUN go build -ldflags "-s -w -X github.com/coredns/coredns/coremain.GitCommit=${REVISION} -X main.pluginVersion=${VERSION}" -o coredns cmd/coredns.go
# Update CA Certs
FROM docker.io/library/alpine:3.21 AS certs
RUN apk --update --no-cache add ca-certificates
# Final Build
FROM scratch
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
COPY --from=builder /build/coredns .
EXPOSE 53 53/udp
ENTRYPOINT ["/coredns"]