Update probetest container images to build binary and reduce final image size with multiple stages

This commit is contained in:
Shelikhoo 2025-08-05 16:08:43 +01:00 committed by Shelikhoo
parent ca07f57448
commit 14b8cde3da
No known key found for this signature in database
GPG key ID: 00FC450280CBED3C
2 changed files with 34 additions and 2 deletions

View file

@ -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"

View file

@ -24,6 +24,13 @@ but you should use TLS in production.
To build the probe server, run To build the probe server, run
```go build``` ```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 To deploy the probe server, first set the necessary env variables with
``` ```
export HOSTNAMES=${YOUR HOSTNAMES} export HOSTNAMES=${YOUR HOSTNAMES}