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:
13
Dockerfile
13
Dockerfile
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user