Docker/ gets the same deployment shapes as DriverVault: plain, SeaweedFS in the stack, SeaweedFS split into its roles, and an external S3 endpoint, each as a build-from-source and a registry compose file with an .env example of the same name, plus a README. The API Server now reads PB_S3_* on boot and points PocketBase's file storage at the bucket (only when the settings differ), then asks PocketBase to test it. It never turns S3 off. Plugin state gets an api_data volume, since the image could not write plugins.json. The PocketBase image pinned v0.22.21, which cannot run the v0.23+ migrations or `superuser upsert`; it now pins v0.39.11. Starting from an empty database also exposed two migration bugs: the seed tried to create a passwordless account, and the documents collection saved its self-relation with a blank target. Both are fixed; databases that already ran them are unaffected. Verified on Docker: the SeaweedFS and split stacks come up healthy from an empty database, uploads land in the bucket, and a restart is a no-op. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.6 KiB
Docker
44 lines
1.6 KiB
Docker
# 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"]
|