Files
PilotVault/Docker-AIO/Dockerfile.seaweedfs.split
T
tajniak81andClaude Opus 5.5 3962530841 Docker-AIO: S3 and SeaweedFS variants, matching DriverVault
Docker-AIO gets the same deployment shapes as DriverVault: plain,
SeaweedFS, SeaweedFS split into its roles, and an external S3 endpoint,
each as a build-from-source and a prod compose file with an .env example
of the same name, plus a README. The from-source SeaweedFS files run the
store as side containers; the prod ones build Dockerfile.seaweedfs or
Dockerfile.seaweedfs.split, which bake `weed server -s3` or its five
separate roles into the image under supervisord.

The image is rebuilt around PilotVault's real layout. The old Dockerfile
copied "Web App/ui" and "Web App/main.go", which no longer exist, and
pinned PocketBase 0.22.21, which cannot run the migrations; it now builds
"Web App/web" + "Web App/server" and pins 0.39.11. Unlike DriverVault's
nginx front, the Go BFF keeps serving the UI on 8090. Every process runs
as an unprivileged user, plugins.json gets an /app/data volume, the
container is healthy only when every process answers, and no default
superuser credentials are baked in.

Verified on Docker from an empty database: plain, both SeaweedFS
from-source and both baked prod variants come up healthy, document
uploads land in the bucket and download back. The external-S3 files are
checked with `docker compose config` only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 18:08:53 +01:00

406 lines
18 KiB
Docker

# syntax=docker/dockerfile:1
#
# All-in-one PilotVault image WITH the object store inside: PocketBase + API
# Server + Web App, plus SeaweedFS split into its roles — master, volume, filer,
# S3 gateway and the admin UI — each its own supervisord program in the same
# container.
#
# This is Dockerfile with the SeaweedFS containers of
# docker-compose.seaweedfs.split.yml folded in. What the split still buys in
# here: per-role restart under supervisord, per-role metrics ports, and the
# admin UI, where S3 identities are minted and revoked. What it costs: a new
# SeaweedFS means a rebuild (--build-arg SEAWEED_VERSION).
#
# BUILD CONTEXT MUST BE THE REPO ROOT (this file COPYs from "API Server/" and
# "Web App/"). The root .dockerignore keeps the sibling apps out of it. From
# E:\VS Code Projects\PilotVault:
#
# docker build -f "Docker-AIO/Dockerfile.seaweedfs.split" -t pilotvault-aio-seaweedfs-split .
#
# Run it (everything starts together):
#
# docker run -d --name pilotvault -p 8090:8090 -p 8080:8080 -p 8070:8070 \
# -e POCKETBASE_ADMIN_EMAIL=admin@example.com \
# -e POCKETBASE_ADMIN_PASSWORD=change-me-long-password \
# -p 127.0.0.1:23646:23646 \
# -e PB_S3_ACCESS_KEY=pilotvault -e PB_S3_SECRET=change-me \
# -e WEED_ADMIN_PASSWORD=change-me \
# -v pilotvault_pb:/pb/pb_data -v pilotvault_api:/app/data \
# -v pilotvault_seaweed:/seaweed/data \
# -v pilotvault_seaweed_admin:/seaweed/admin \
# pilotvault-aio-seaweedfs-split
#
# Then: web app on http://host:8090/, PocketBase admin on http://host:8070/_/,
# and the SeaweedFS admin UI on http://127.0.0.1:23646/. On first boot the S3
# gateway's program creates the bucket and seeds PocketBase's identity,
# PocketBase runs its migrations, and the API Server points PocketBase's file
# storage at the bucket.
#
# Port map inside the container (only 8090, 8080, 8070 and 23646 are meant to
# be published; every SeaweedFS role but the admin UI binds loopback):
#
# 8070 PocketBase
# 8080 API Server ← which is why the volume server is NOT on its
# 8081 SeaweedFS volume usual 8080 here
# 8090 Web App
# 8333 SeaweedFS S3 gateway (PocketBase's endpoint)
# 8888 SeaweedFS filer
# 9333 SeaweedFS master
# 23646 SeaweedFS admin UI (publish on loopback, behind a proxy if remote)
# SeaweedFS release to bake in, pinned like PB_VERSION so a rebuild months from
# now brings up the same one. Same tag the compose SeaweedFS files run as
# SEAWEED_IMAGE. Override with --build-arg SEAWEED_VERSION=... to upgrade.
ARG SEAWEED_VERSION="4.45"
# =============================================================================
# Stage 1 — the API Server's embedded Vue panel (-> /internal/api/dist)
# =============================================================================
FROM node:22-alpine3.24 AS panel
WORKDIR /panel
COPY ["API Server/panel/package.json", "API Server/panel/package-lock.json", "./"]
RUN npm ci
COPY ["API Server/panel/", "./"]
# vite.config.js writes the build to ../internal/api/dist.
RUN npm run build
# =============================================================================
# Stage 2 — the API Server static binary (go.mod pins go 1.26)
# =============================================================================
FROM golang:1.26-alpine AS api-build
WORKDIR /src
COPY ["API Server/go.mod", "API Server/go.sum", "./"]
RUN go mod download
COPY ["API Server/cmd/", "./cmd/"]
COPY ["API Server/internal/", "./internal/"]
# 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 — the Web App's Vue UI (Web App/web -> /server/dist)
# =============================================================================
FROM node:22-alpine3.24 AS web
WORKDIR /web
COPY ["Web App/web/package.json", "Web App/web/package-lock.json", "./"]
RUN npm ci
COPY ["Web App/web/", "./"]
# vite.config.js writes the build to ../server/dist.
RUN npm run build
# =============================================================================
# Stage 4 — the Web App BFF static binary (Web App/server, go.mod pins go 1.24)
# =============================================================================
FROM golang:1.24-alpine AS web-build
WORKDIR /src
COPY ["Web App/server/go.mod", "Web App/server/go.sum", "./"]
RUN go mod download
COPY ["Web App/server/", "./"]
# Overlay the freshly built UI so //go:embed all:dist picks it up.
COPY --from=web /server/dist ./dist
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \
-o /out/web-app .
# =============================================================================
# Stage 5 — SeaweedFS: the one static binary from the official image.
# SEAWEED_VERSION is declared at the top of the file: an ARG used in a FROM has
# to be global, and one declared here would expand to nothing.
# =============================================================================
FROM chrislusf/seaweedfs:${SEAWEED_VERSION} AS seaweed
# =============================================================================
# Stage 6 — runtime: everything under supervisord
# =============================================================================
FROM alpine:3.24
# Pinned so a rebuild months from now produces the same PocketBase. It must be
# v0.23 or newer: the bundled migrations use the v0.23+ JSVM API and the
# pocketbase program uses `superuser upsert`. Override to upgrade
# (--build-arg PB_VERSION=0.40.0); set it to empty to resolve the latest release
# at build time, which needs an unauthenticated GitHub API call (rate-limited to
# 60/hour per IP).
ARG PB_VERSION="0.39.11"
# Provided automatically by BuildKit (amd64 / arm64).
ARG TARGETARCH="amd64"
RUN apk add --no-cache ca-certificates tzdata unzip wget supervisor
# Unprivileged account for every process; supervisord drops to it. Nothing here
# binds a port below 1024, so nothing needs to stay root.
RUN addgroup -S app && adduser -S -G app app
# PocketBase from the official release (pinned via PB_VERSION, else latest).
WORKDIR /pb
RUN set -eux; \
ver="${PB_VERSION}"; \
if [ -z "$ver" ]; then \
ver="$(wget -qO- https://api.github.com/repos/pocketbase/pocketbase/releases/latest \
| grep -o '"tag_name": *"v[^"]*"' | head -1 | sed -E 's/.*"v([^"]+)".*/\1/')"; \
fi; \
echo "Installing PocketBase v${ver} (${TARGETARCH})"; \
wget -q -O /tmp/pb.zip \
"https://github.com/pocketbase/pocketbase/releases/download/v${ver}/pocketbase_${ver}_linux_${TARGETARCH}.zip"; \
unzip /tmp/pb.zip -d /pb; \
rm /tmp/pb.zip
# JS migrations (schema + seed accounts), applied by PocketBase on every serve.
COPY ["API Server/pocketbase/pb_migrations/", "/pb/pb_migrations/"]
# The two Go binaries.
COPY --from=api-build /out/api-server /usr/local/bin/api-server
COPY --from=web-build /out/web-app /usr/local/bin/web-app
COPY --from=seaweed /usr/bin/weed /usr/local/bin/weed
# Bucket and identity seed, run by the S3 gateway's program before it serves.
# Two jobs, both idempotent, so every boot re-applies the values from the
# environment and changes nothing else — which is also how a rotated
# PB_S3_SECRET reaches the gateway:
#
# 1. create the bucket — PocketBase never issues a CreateBucket of its own;
# 2. write PocketBase's S3 identity into the filer's IAM store.
#
# (2) is why the gateway below runs with neither an -config file nor
# AWS_ACCESS_KEY_ID: the env vars are the lowest-priority credential source in
# SeaweedFS, read only while the filer's store is empty, so the first identity
# added in the admin UI would silently displace them and lock PocketBase out.
# Seeding the store the admin UI itself writes leaves one source of truth, and
# PocketBase's key shows under Object Store → Users like any other.
#
# The closing grep is the gate: an empty IAM store means the gateway would come
# up in its allow-anyone default, so this fails loudly instead and the gateway
# never starts (supervisord retries it, and the healthcheck stays red).
RUN cat > /usr/local/bin/seaweedfs-seed <<'SEED'
#!/bin/sh
set -e
: "${PB_S3_ACCESS_KEY:?seaweedfs-seed: PB_S3_ACCESS_KEY is required}"
: "${PB_S3_SECRET:?seaweedfs-seed: PB_S3_SECRET is required}"
bucket="${PB_S3_BUCKET:-pilotvault}"
shell() { weed shell -master=127.0.0.1:9333 -filer=127.0.0.1:8888; }
printf '%s\n' \
"s3.bucket.create -name $bucket" \
"s3.configure -user pilotvault -access_key $PB_S3_ACCESS_KEY -secret_key $PB_S3_SECRET -actions Admin -apply" \
| shell
if ! echo "s3.configure" | shell | grep -q "$PB_S3_ACCESS_KEY"; then
echo "seaweedfs-seed: PocketBase's identity is not in the filer's IAM store; refusing to start the gateway" >&2
exit 1
fi
SEED
RUN chmod +x /usr/local/bin/seaweedfs-seed
# supervisord runs the eight processes and keeps them alive. Priorities only
# order the launches; readiness is the `until wget` loop in front of each
# program that needs another one up, the same chain the compose split spells
# out with depends_on + healthchecks: master → volume → filer → seed + S3 →
# PocketBase → API Server → Web App.
RUN cat > /etc/supervisord.conf <<'SUPERVISOR'
[supervisord]
nodaemon=true
user=root
pidfile=/run/supervisord.pid
logfile=/dev/null
logfile_maxbytes=0
; SeaweedFS master: volume/topology metadata and file ids.
[program:seaweedfs-master]
directory=/app
user=app
command=/usr/local/bin/weed master -ip=127.0.0.1 -ip.bind=127.0.0.1 -port=9333 -mdir=/seaweed/data -volumeSizeLimitMB=1024 -metricsPort=9324
priority=1
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
; SeaweedFS volume server: where the bytes land. On 8081 because 8080 is the
; API Server in this container. -max=0 sizes itself from free disk rather than
; the default cap of 8 volumes.
[program:seaweedfs-volume]
directory=/app
user=app
command=/bin/sh -c 'until wget -qO- http://127.0.0.1:9333/cluster/status >/dev/null 2>&1; do echo "waiting for seaweedfs master..."; sleep 1; done; exec /usr/local/bin/weed volume -master=127.0.0.1:9333 -ip=127.0.0.1 -ip.bind=127.0.0.1 -port=8081 -dir=/seaweed/data -max=0 -metricsPort=9325'
priority=2
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
; SeaweedFS filer: the directory tree over the flat volume store — buckets,
; object keys — and the IAM store the S3 identities live in. -defaultStoreDir
; keeps its embedded leveldb on the data volume so they survive a recreate.
[program:seaweedfs-filer]
directory=/app
user=app
command=/bin/sh -c 'until wget -qO- http://127.0.0.1:8081/healthz >/dev/null 2>&1; do echo "waiting for seaweedfs volume..."; sleep 1; done; exec /usr/local/bin/weed filer -master=127.0.0.1:9333 -ip=127.0.0.1 -ip.bind=127.0.0.1 -port=8888 -defaultStoreDir=/seaweed/data -metricsPort=9326'
priority=3
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
; SeaweedFS S3 gateway: PocketBase's endpoint. Seeds the bucket and identity
; first (see /usr/local/bin/seaweedfs-seed) and never serves if that fails. No
; -config file: with only -filer given, credentials come from the filer's IAM
; store, which is what lets the admin UI add and revoke identities without a
; restart.
[program:seaweedfs-s3]
directory=/app
user=app
command=/bin/sh -c 'until wget -qO- http://127.0.0.1:8888/healthz >/dev/null 2>&1; do echo "waiting for seaweedfs filer..."; sleep 1; done; /usr/local/bin/seaweedfs-seed && exec /usr/local/bin/weed s3 -filer=127.0.0.1:8888 -ip.bind=127.0.0.1 -port=8333 -metricsPort=9327'
priority=4
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
; SeaweedFS admin UI: cluster view, buckets, maintenance, and Object Store →
; Users. It can mint credentials for the bucket, and weed leaves auth off
; entirely when WEED_ADMIN_PASSWORD is empty — so an empty password means no
; panel at all rather than an open one. -dataDir persists the session key and
; the maintenance-task settings.
[program:seaweedfs-admin]
directory=/app
user=app
command=/bin/sh -c 'if [ -z "$WEED_ADMIN_PASSWORD" ]; then echo "seaweedfs-admin: WEED_ADMIN_PASSWORD is empty; refusing to serve an unauthenticated panel" >&2; exit 1; fi; until wget -qO- http://127.0.0.1:9333/cluster/status >/dev/null 2>&1; do echo "waiting for seaweedfs master..."; sleep 1; done; exec /usr/local/bin/weed admin -port=23646 -master=127.0.0.1:9333 -dataDir=/seaweed/admin -metricsPort=9328'
priority=5
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
; PocketBase: wait for the S3 gateway — PocketBase is the process that reads
; and writes the objects. Then upsert the superuser and serve with the
; bundled migrations.
[program:pocketbase]
directory=/app
user=app
command=/bin/sh -c 'until wget -qO- http://127.0.0.1:8333/healthz >/dev/null 2>&1; do echo "waiting for seaweedfs s3..."; sleep 1; done; /pb/pocketbase superuser upsert "$POCKETBASE_ADMIN_EMAIL" "$POCKETBASE_ADMIN_PASSWORD" --dir=/pb/pb_data 2>/dev/null || echo "warning: superuser upsert failed" >&2; exec /pb/pocketbase serve --http=0.0.0.0:8070 --dir=/pb/pb_data --migrationsDir=/pb/pb_migrations'
priority=10
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
; API Server: wait for PocketBase to be healthy, then start. On boot it
; points PocketBase's file storage at the bucket (PB_S3_*) and asks it to
; prove the gateway is reachable. It keeps one file on disk, plugins.json, on
; the /app/data volume (PLUGINS_FILE).
[program:api-server]
directory=/app
user=app
command=/bin/sh -c 'until wget -qO- http://127.0.0.1:8070/api/health >/dev/null 2>&1; do echo "waiting for pocketbase..."; sleep 1; done; exec /usr/local/bin/api-server'
priority=20
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
; Web App: the Go BFF serving the UI on :8090 and proxying /api/* to the API
; Server on loopback. Waits for the API Server so the first page load works.
[program:web-app]
directory=/app
user=app
command=/bin/sh -c 'until wget -qO- http://127.0.0.1:8080/healthz >/dev/null 2>&1; do echo "waiting for api-server..."; sleep 1; done; exec /usr/local/bin/web-app'
priority=30
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
SUPERVISOR
# The entrypoint stays root only long enough to make the data volumes writable
# by the app user, then hands off to supervisord. The chown matters for a host
# bind mount, which arrives owned by root rather than inheriting the image's
# owner.
RUN cat > /entrypoint.sh <<'ENTRY'
#!/bin/sh
set -e
for dir in /pb/pb_data /app/data /seaweed/data /seaweed/admin; do
mkdir -p "$dir"
if [ "$(stat -c %U "$dir" 2>/dev/null)" != "app" ]; then
echo "entrypoint: taking ownership of $dir"
chown -R app:app "$dir"
fi
done
exec supervisord -c /etc/supervisord.conf
ENTRY
RUN chmod +x /entrypoint.sh
# Everything is local to this container. WEBAPP_URL is what the panel status
# page probes.
#
# File storage is on by construction: the gateway is in this image, at a fixed
# loopback address, path style because a self-hosted gateway has no per-bucket
# DNS. The region is a formality SeaweedFS ignores and PocketBase insists on.
# supervisord passes these through to the API Server, which writes them into
# PocketBase's settings on every boot. Only record files move — the document
# store's blobs; the database and PocketBase's own backups stay on /pb/pb_data.
ENV API_ADDR=:8080 \
POCKETBASE_URL=http://127.0.0.1:8070 \
CORS_ALLOW_ORIGINS=http://localhost:8090 \
WEBAPP_URL=http://127.0.0.1:8090 \
PLUGINS_FILE=/app/data/plugins.json \
ADDR=:8090 \
API_BASE=http://127.0.0.1:8080 \
PB_S3_ENABLED=true \
PB_S3_ENDPOINT=http://127.0.0.1:8333 \
PB_S3_BUCKET=pilotvault \
PB_S3_REGION=us-east-1 \
PB_S3_FORCE_PATH_STYLE=true \
WEED_ADMIN_USER=admin
# Required at runtime (no safe defaults): POCKETBASE_ADMIN_EMAIL,
# POCKETBASE_ADMIN_PASSWORD; PB_S3_ACCESS_KEY, PB_S3_SECRET (the identity seeded
# into SeaweedFS AND what PocketBase authenticates with — the gateway refuses to
# start without them); WEED_ADMIN_PASSWORD (the admin UI refuses to start
# without it). Optional: WEED_ADMIN_READONLY_USER / _PASSWORD add a view-only
# login to the admin UI. Pass them with `docker run -e ...`.
# Four volumes. /pb/pb_data: the database, documents uploaded before S3 was on,
# PocketBase's own backups. /app/data: the API Server's plugins.json.
# /seaweed/data: master, volume and filer share it, in exactly the layout
# `weed server -dir` writes, so a SEAWEED_DATA volume from either compose
# SeaweedFS file mounts here unchanged, and vice versa. /seaweed/admin: the admin
# UI's session key and maintenance-task state, small and no part of the object
# store. All pre-created and owned by app so a fresh named volume inherits that
# ownership.
RUN mkdir -p /pb/pb_data /app/data /seaweed/data /seaweed/admin \
&& chown -R app:app /pb /app /seaweed
VOLUME ["/pb/pb_data", "/app/data", "/seaweed/data", "/seaweed/admin"]
WORKDIR /app
# 8090 = Web App, 8080 = API Server + embedded panel, 8070 = PocketBase admin,
# 23646 = SeaweedFS admin UI.
EXPOSE 8090 8080 8070 23646
# Every process must answer, so a wedged component shows up in `docker ps`
# instead of a container that looks up while part of it is dead. start-period
# covers the SeaweedFS chain plus the first-boot migrations on a cold database.
HEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=3 \
CMD wget -qO- http://127.0.0.1:9333/cluster/status >/dev/null 2>&1 \
&& wget -qO- http://127.0.0.1:8081/healthz >/dev/null 2>&1 \
&& wget -qO- http://127.0.0.1:8888/healthz >/dev/null 2>&1 \
&& wget -qO- http://127.0.0.1:8333/healthz >/dev/null 2>&1 \
&& wget -qO- http://127.0.0.1:23646/health >/dev/null 2>&1 \
&& wget -qO- http://127.0.0.1:8070/api/health >/dev/null 2>&1 \
&& wget -qO- http://127.0.0.1:8080/healthz >/dev/null 2>&1 \
&& wget -qO- http://127.0.0.1:8090/ >/dev/null 2>&1 \
|| exit 1
ENTRYPOINT ["/entrypoint.sh"]