# Stage 1: Frontend build FROM node:26-alpine@sha256:c6ad9e9c1d80f6eb607c26b4b0a132ff7a2344fad1c78ea3baa2a7d4c8de6d94 AS frontend WORKDIR /ui ARG APP_VERSION COPY ./ui/leafwiki-ui/package.json ./package.json COPY ./ui/leafwiki-ui/package-lock.json ./package-lock.json RUN npm ci --ignore-scripts COPY ./ui/leafwiki-ui/ ./ RUN VITE_API_URL=/ APP_VERSION=${APP_VERSION} npm run build # Stage 2: Go backend build FROM golang:1.27.3-alpine@sha256:d200d2dd76b03a99b52651fd1325aff7dcd35422c35c01bac56571b0507f3deb AS builder ARG APP_VERSION ARG GOOS ARG GOARCH ARG CGO_ENABLED=0 ARG OUTPUT=leafwiki ENV GOOS=${GOOS} ENV GOARCH=${GOARCH} ENV CGO_ENABLED=${CGO_ENABLED} WORKDIR /build COPY go.mod go.sum ./ RUN go mod download COPY . . # Copy built frontend COPY --from=frontend /ui/dist ./internal/http/dist # -tags nomsgpack drops gin's unused MessagePack codec (~5MB with -trimpath). RUN go build -trimpath -tags nomsgpack \ -ldflags="-s -w -X github.com/perber/wiki/internal/http.EmbedFrontend=true -X github.com/perber/wiki/internal/http.Environment=production -X main.Version=${APP_VERSION}" \ -o /out/${OUTPUT} ./cmd/leafwiki