-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDockerfile
37 lines (27 loc) · 953 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
FROM golang:1.16 AS build
WORKDIR /workspace
ENV GO111MODULE=on
RUN apt update -qq && apt install -qq -y git bash curl g++
# Fetch binary early because to allow more caching
COPY scripts scripts
COPY testdata testdata
RUN ./scripts/fetch-test-binaries.sh
COPY src src
# Build
RUN cd src; go mod download
RUN cd src; CGO_ENABLED=0 go build -o webhook -ldflags '-w -extldflags "-static"' .
#Test
ARG TEST_ZONE_NAME
RUN \
if [ -n "$TEST_ZONE_NAME" ]; then \
cd src; \
CCGO_ENABLED=0 TEST_ZONE_NAME="$TEST_ZONE_NAME" go test -v .; \
fi
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:debug
WORKDIR /
COPY --from=build /workspace/src/webhook /app/webhook
USER nonroot:nonroot
ENTRYPOINT ["/app/webhook"]
LABEL org.opencontainers.image.source https://github.com/k8s-at-home/dnsmadeeasy-webhook