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>
306 lines
14 KiB
Docker
306 lines
14 KiB
Docker
# syntax=docker/dockerfile:1
|
|
#
|
|
# All-in-one PilotVault image WITH the object store inside: PocketBase + API
|
|
# Server + Web App, plus SeaweedFS as one `weed server -s3` process — master,
|
|
# volume, filer and S3 gateway as goroutines — under supervisord in the same
|
|
# container.
|
|
#
|
|
# This is Dockerfile with the SeaweedFS containers of
|
|
# docker-compose.seaweedfs.yml folded in. What it costs: a new SeaweedFS
|
|
# means a rebuild (--build-arg SEAWEED_VERSION). For per-role restart, metrics
|
|
# and the admin UI, see Dockerfile.seaweedfs.split.
|
|
#
|
|
# 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" -t pilotvault-aio-seaweedfs .
|
|
#
|
|
# 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 \
|
|
# -e PB_S3_ACCESS_KEY=pilotvault -e PB_S3_SECRET=change-me \
|
|
# -v pilotvault_pb:/pb/pb_data -v pilotvault_api:/app/data \
|
|
# -v pilotvault_seaweed:/seaweed/data \
|
|
# pilotvault-aio-seaweedfs
|
|
#
|
|
# Then: web app on http://host:8090/ and PocketBase admin on http://host:8070/_/.
|
|
# On first boot PocketBase's program creates the bucket, PocketBase runs its
|
|
# migrations, and the API Server points PocketBase's file storage at the bucket.
|
|
#
|
|
# Port map inside the container (only 8090, 8080 and 8070 are meant to be
|
|
# published):
|
|
#
|
|
# 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
|
|
|
|
# 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
|
|
|
|
# supervisord runs the five 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 file spells out
|
|
# with depends_on + healthchecks: SeaweedFS → bucket → 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: one process, four roles — master, volume, filer and the S3
|
|
; gateway. -dir is the only state it keeps. Every role advertises and binds
|
|
; 127.0.0.1: PocketBase is the only client and lives in here, and the volume
|
|
; server (on 8081 because 8080 is the API Server) serves file content by id
|
|
; with no authentication at all.
|
|
;
|
|
; SeaweedFS falls back to AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY when started
|
|
; without an -s3.config file, and configuring one identity is what takes the
|
|
; gateway out of its default allow-anyone mode. They are the PB_S3_* pair
|
|
; PocketBase authenticates with, mapped here so there is one pair to set — and
|
|
; an empty pair means no gateway rather than an open one.
|
|
[program:seaweedfs]
|
|
directory=/app
|
|
user=app
|
|
command=/bin/sh -c 'if [ -z "$PB_S3_ACCESS_KEY" ] || [ -z "$PB_S3_SECRET" ]; then echo "seaweedfs: PB_S3_ACCESS_KEY and PB_S3_SECRET are required; refusing to start an unauthenticated gateway" >&2; exit 1; fi; export AWS_ACCESS_KEY_ID="$PB_S3_ACCESS_KEY" AWS_SECRET_ACCESS_KEY="$PB_S3_SECRET"; exec /usr/local/bin/weed server -dir=/seaweed/data -ip=127.0.0.1 -ip.bind=127.0.0.1 -volume.port=8081 -s3 -master.volumeSizeLimitMB=1024'
|
|
priority=1
|
|
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 create the bucket: PocketBase never issues a
|
|
; CreateBucket of its own and SeaweedFS will not conjure one on first upload.
|
|
; Creating a bucket that already exists is a no-op, and `|| true` keeps a
|
|
; restart from being blocked — a genuinely broken gateway is reported by the
|
|
; API Server's own S3 check at boot. 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..."; sleep 1; done; echo "s3.bucket.create -name $PB_S3_BUCKET" | /usr/local/bin/weed shell -master=127.0.0.1:9333 || true; /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; 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
|
|
|
|
# Required at runtime (no safe defaults): POCKETBASE_ADMIN_EMAIL,
|
|
# POCKETBASE_ADMIN_PASSWORD; PB_S3_ACCESS_KEY, PB_S3_SECRET (the gateway's single
|
|
# identity AND what PocketBase authenticates with — the gateway refuses to start
|
|
# without them). Pass them with `docker run -e ...`.
|
|
|
|
# Three 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: everything SeaweedFS keeps, in the layout `weed server -dir`
|
|
# writes — the same one the split image's master, volume and filer share, so a
|
|
# SEAWEED_DATA volume from any of the SeaweedFS compose files mounts here
|
|
# unchanged, and vice versa. 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 \
|
|
&& chown -R app:app /pb /app /seaweed
|
|
VOLUME ["/pb/pb_data", "/app/data", "/seaweed/data"]
|
|
WORKDIR /app
|
|
# 8090 = Web App, 8080 = API Server + embedded panel, 8070 = PocketBase admin.
|
|
# Nothing of SeaweedFS is exposed: it binds loopback only.
|
|
EXPOSE 8090 8080 8070
|
|
|
|
# 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 SeaweedFS coming up 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:8333/healthz >/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"]
|