# Admin console image: builds the SPA (node), embeds it into the Go admin # binary, and ships a static scratch runtime. Build context is the repo root. # Stage 1: build the admin SPA. FROM node:22-alpine AS web WORKDIR /web ENV npm_config_registry=https://registry.npmmirror.com COPY admin-frontend/package.json admin-frontend/package-lock.json* ./ RUN npm ci || npm install COPY admin-frontend/ ./ RUN npm run build # Stage 2: build the Go admin binary with the SPA embedded. FROM golang:1.23-alpine AS build ENV GOPROXY=https://goproxy.cn,direct WORKDIR /src COPY api/go.mod api/go.sum ./ RUN go mod download COPY api/ ./ RUN rm -rf internal/adminweb/dist && mkdir -p internal/adminweb/dist COPY --from=web /web/dist/ internal/adminweb/dist/ RUN CGO_ENABLED=0 go build -o /out/admin ./cmd/admin # Stage 3: minimal runtime. FROM scratch COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=build /out/admin /admin EXPOSE 8080 ENTRYPOINT ["/admin"]