# --- build stage ---
FROM golang:1.25-alpine AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags='-s -w' \
    -o /out/automc-tutorials ./cmd/automc-tutorials

# --- runtime stage ---
# Image carries only the binary. Content is provided at runtime via a volume
# mount at /content (typically a Longhorn RWX PVC populated by `git pull` or
# rsync from an admin shell). Live edits + SIGHUP reload = no rebuild needed.
FROM gcr.io/distroless/static-debian12:nonroot
WORKDIR /app
COPY --from=build /out/automc-tutorials /app/automc-tutorials
EXPOSE 8080
ENV ADDR=:8080 CONTENT_DIR=/content DEFAULT_LOCALE=en
VOLUME ["/content"]
USER 65532:65532
ENTRYPOINT ["/app/automc-tutorials"]
