-
Notifications
You must be signed in to change notification settings - Fork 19
/
Dockerfile
59 lines (36 loc) · 1.95 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM --platform=$BUILDPLATFORM golang:1.22.3-alpine3.18@sha256:d1a601b64de09e2fa38c95e55838961811d5ca11062a8f4230a5c434b3ae2a34 as build
WORKDIR /src
# renovate: datasource=github-tags depName=DNSCrypt/dnscrypt-proxy
ARG DNSCRYPT_PROXY_VERSION=2.1.5
ADD https://github.com/DNSCrypt/dnscrypt-proxy/archive/${DNSCRYPT_PROXY_VERSION}.tar.gz /tmp/dnscrypt-proxy.tar.gz
RUN tar xzf /tmp/dnscrypt-proxy.tar.gz --strip 1
WORKDIR /src/dnscrypt-proxy
ARG TARGETOS TARGETARCH TARGETVARIANT
RUN --mount=type=cache,target=/home/nonroot/.cache/go-build,uid=65532,gid=65532 \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=${TARGETVARIANT#v} go build -v -ldflags="-s -w" -mod vendor
WORKDIR /config
RUN cp -a /src/dnscrypt-proxy/example-* ./
COPY dnscrypt-proxy.toml ./
ARG NONROOT_UID=65532
ARG NONROOT_GID=65532
RUN addgroup -S -g ${NONROOT_GID} nonroot \
&& adduser -S -g nonroot -h /home/nonroot -u ${NONROOT_UID} -D -G nonroot nonroot
# ----------------------------------------------------------------------------
FROM --platform=$BUILDPLATFORM golang:1.22.3-alpine3.18@sha256:d1a601b64de09e2fa38c95e55838961811d5ca11062a8f4230a5c434b3ae2a34 as probe
WORKDIR /src/dnsprobe
ARG TARGETOS TARGETARCH TARGETVARIANT
COPY dnsprobe/ ./
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=${TARGETVARIANT#v} go build -o /usr/local/bin/dnsprobe .
# ----------------------------------------------------------------------------
FROM scratch
COPY --from=build /src/dnscrypt-proxy/dnscrypt-proxy /usr/local/bin/
COPY --from=probe /usr/local/bin/dnsprobe /usr/local/bin/
COPY --from=build /etc/passwd /etc/group /etc/
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build --chown=nonroot:nonroot /home/nonroot /home/nonroot
COPY --from=build --chown=nonroot:nonroot /config /config
USER nonroot
ENV PATH=$PATH:/usr/local/bin
ENTRYPOINT [ "dnscrypt-proxy" ]
CMD [ "-config", "/config/dnscrypt-proxy.toml" ]