Switch demo service to a Go binary on scratch

The python:3.12-slim base pushed a 30 MB layer that timed out on the way
to Harbor (Cloudflare 524). A static Go binary keeps the image near 5 MB
with the same endpoints, port and APP_MESSAGE variable.
This commit is contained in:
2026-10-23 08:50:10 +00:00
parent 2c21665d0e
commit fdb7ee666d
5 changed files with 66 additions and 47 deletions

View File

@@ -1,9 +1,14 @@
# The AISP build gateway only allows base images from approved mirrors, written with the
# full host (docker.io/..., harbor.vts-ai.space/...).
FROM docker.io/library/python:3.12-slim
FROM docker.io/library/golang:1.23-alpine AS build
WORKDIR /src
COPY go.mod main.go ./
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/server .
WORKDIR /app
COPY app.py .
# A static binary on scratch keeps the pushed image to a few MB; large layers time out
# on the way to Harbor.
FROM scratch
COPY --from=build /out/server /server
# AISP enforces PodSecurity "restricted": run as a non-root UID on a port above 1024.
USER 10001
@@ -11,4 +16,4 @@ ENV PORT=8080 \
APP_MESSAGE="Hello from AISP"
EXPOSE 8080
CMD ["python", "-u", "app.py"]
ENTRYPOINT ["/server"]