38 lines
1.1 KiB
Text
38 lines
1.1 KiB
Text
|
|
# Production build for go-doc.
|
||
|
|
# Build context must be the workspace root (/home/dnoulet/go).
|
||
|
|
# Documents under go-doc/data/docs are copied into the image at /data/docs.
|
||
|
|
# Persistence must mount only /data/comments so this tree stays visible.
|
||
|
|
FROM node:22-alpine AS frontend
|
||
|
|
|
||
|
|
WORKDIR /src/frontend
|
||
|
|
COPY go-doc/frontend/package.json go-doc/frontend/package-lock.json ./
|
||
|
|
RUN npm ci --no-audit --no-fund
|
||
|
|
COPY go-doc/frontend/ ./
|
||
|
|
RUN npm run build
|
||
|
|
|
||
|
|
FROM golang:1.27-alpine AS builder
|
||
|
|
|
||
|
|
RUN apk add --no-cache git ca-certificates
|
||
|
|
|
||
|
|
WORKDIR /src
|
||
|
|
COPY go-doc/backend/go.mod go-doc/backend/go.sum ./
|
||
|
|
RUN go mod download
|
||
|
|
|
||
|
|
COPY go-doc/backend/ backend/
|
||
|
|
COPY --from=frontend /src/frontend/dist/ backend/webui/dist/
|
||
|
|
COPY go-doc/data/docs /staged/docs
|
||
|
|
RUN chmod -R a+rX /staged/docs && mkdir -p /empty/comments
|
||
|
|
RUN cd backend && CGO_ENABLED=0 go build -trimpath -ldflags '-s -w' -o /out/godoc .
|
||
|
|
|
||
|
|
FROM gcr.io/distroless/static-debian12:nonroot
|
||
|
|
|
||
|
|
COPY --from=builder /out/godoc /godoc
|
||
|
|
COPY --from=builder /staged/docs /data/docs
|
||
|
|
COPY --from=builder /empty/comments /data/comments
|
||
|
|
|
||
|
|
EXPOSE 8080
|
||
|
|
|
||
|
|
ENV GO_DOC_DATA_DIR=/data
|
||
|
|
|
||
|
|
ENTRYPOINT ["/godoc", "-addr", "0.0.0.0:8080"]
|