# syntax=docker/dockerfile:1 # ---- Stage 1: build the embedded Vue panel ---- # vite.config.js writes the build to ../internal/api/dist, i.e. /internal/api/dist # here, which the Go binary embeds via //go:embed all:dist. FROM node:22-alpine AS panel WORKDIR /panel COPY panel/package.json panel/package-lock.json ./ RUN npm ci COPY panel/ ./ RUN npm run build # ---- Stage 2: build the static Go binary (panel embedded) ---- FROM golang:1.26-alpine AS build WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . # Overlay the freshly built panel so //go:embed all:dist picks it up. COPY --from=panel /internal/api/dist ./internal/api/dist RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \ -o /out/api-server ./cmd/server # ---- Stage 3: minimal runtime ---- FROM alpine:latest RUN apk add --no-cache ca-certificates tzdata \ && adduser -D -u 10001 app \ && mkdir -p /app/data && chown app:app /app/data WORKDIR /app COPY --from=build /out/api-server ./api-server USER app # Plugin enable-state + config is the one thing the API Server keeps on disk. # /app/data is owned by the runtime user, so a named volume mounted there # inherits that ownership and stays writable. ENV PLUGINS_FILE=/app/data/plugins.json VOLUME ["/app/data"] HEALTHCHECK --interval=10s --timeout=3s --start-period=20s --retries=12 \ CMD wget -qO- http://127.0.0.1:8080/healthz || exit 1 # Default listen address (override with API_ADDR). PocketBase URL, CORS origins, # and the optional POCKETBASE_ADMIN_* service account come from env at runtime. ENV API_ADDR=:8080 EXPOSE 8080 ENTRYPOINT ["/app/api-server"]