From 14b8cde3da22c665027889bb1afc50c6d88df207 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Tue, 5 Aug 2025 16:08:43 +0100 Subject: [PATCH] Update probetest container images to build binary and reduce final image size with multiple stages --- probetest/Dockerfile | 29 +++++++++++++++++++++++++++-- probetest/README.md | 7 +++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/probetest/Dockerfile b/probetest/Dockerfile index f73fbc1..63fdd44 100644 --- a/probetest/Dockerfile +++ b/probetest/Dockerfile @@ -1,3 +1,28 @@ -FROM golang:1.23 +FROM docker.io/library/golang:latest AS build -COPY probetest /go/bin + +ADD . /app + +WORKDIR /app/probetest +RUN go get +RUN CGO_ENABLED=0 go build -o probetest -ldflags '-extldflags "-static" -w -s' . + +FROM containers.torproject.org/tpo/tpa/base-images/debian:bookworm as debian-base + +RUN apt-get update && apt-get install -y \ + curl \ + gpg \ + gpg-agent \ + ca-certificates \ + libcap2-bin \ + --no-install-recommends + +FROM scratch + +COPY --from=debian-base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=debian-base /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=build /app/probetest/probetest /bin/probetest + +ENTRYPOINT [ "/bin/probetest" ] + +LABEL org.opencontainers.image.authors="anti-censorship-team@lists.torproject.org" diff --git a/probetest/README.md b/probetest/README.md index 44c7837..41451a9 100644 --- a/probetest/README.md +++ b/probetest/README.md @@ -24,6 +24,13 @@ but you should use TLS in production. To build the probe server, run ```go build``` +Or alternatively: + +``` +cd .. # switch to the repo root directory or $(git rev-parse --show-toplevel) +docker build -t snowflake-probetest -f probetest/Dockerfile . +``` + To deploy the probe server, first set the necessary env variables with ``` export HOSTNAMES=${YOUR HOSTNAMES}