forked from ori-edge/k8s_gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
38 lines (26 loc) · 827 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
FROM --platform=${BUILDPLATFORM} docker.io/library/golang:1.21.5 as builder
ARG LDFLAGS
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
ENV GO111MODULE=on
ENV GOARCH=$TARGETARCH
ENV GOOS=$TARGETOS
RUN go build -ldflags "${LDFLAGS}" -o coredns cmd/coredns.go
FROM debian:stable-slim
RUN apt-get update && apt-get -uy upgrade
RUN apt-get -y install ca-certificates && update-ca-certificates
FROM scratch
COPY --from=0 /etc/ssl/certs /etc/ssl/certs
COPY --from=builder /build/coredns .
EXPOSE 53 53/udp
ENTRYPOINT ["/coredns"]