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>
This commit is contained in:
1 parent
5be676fc97
commit
3962530841
20 files changed
+2582
-122
No files matched your search
+141
-71
@@ -1,30 +1,41 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
#
|
||||
# All-in-one PilotVault image: PocketBase + API Server + Web App in ONE container,
|
||||
# supervised by supervisord. Convenience/demo image — for production run the three
|
||||
# services separately (see Docker/docker-compose.yml).
|
||||
# All-in-one PilotVault image: PocketBase + API Server + Web App (Go BFF) in ONE
|
||||
# container, supervised by supervisord. For per-service restarts and upgrades
|
||||
# run the three services separately instead (see ../Docker).
|
||||
#
|
||||
# BUILD CONTEXT MUST BE THE REPO ROOT (this Dockerfile COPYs from "API Server/"
|
||||
# and "Web App/"). From E:\VS Code Projects\PilotVault run:
|
||||
# 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 -t pilotvault-aio .
|
||||
# docker run -p 8090:8090 -p 8080:8080 -p 8070:8070 \
|
||||
# -v pilotvault_pb:/pb/pb_data pilotvault-aio
|
||||
# docker build -f "Docker-AIO/Dockerfile" -t pilotvault-aio .
|
||||
#
|
||||
# Internal ports (loopback-wired): PocketBase 8070, API Server 8080, Web App 8090.
|
||||
# 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 \
|
||||
# -v pilotvault_pb:/pb/pb_data -v pilotvault_api:/app/data \
|
||||
# pilotvault-aio
|
||||
#
|
||||
# Then: web app on http://host:8090/, the API Server panel on http://host:8080/,
|
||||
# PocketBase admin on http://host:8070/_/. On first boot PocketBase upserts its
|
||||
# superuser and runs the bundled migrations (collections + the baseline org +
|
||||
# the superadmin@pilotvault.local login). Every step is idempotent.
|
||||
|
||||
# =============================================================================
|
||||
# Stage 1 — build the API Server's embedded Vue panel (-> internal/api/dist)
|
||||
# Stage 1 — the API Server's embedded Vue panel (-> /internal/api/dist)
|
||||
# =============================================================================
|
||||
FROM node:22-alpine AS panel
|
||||
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 — build the API Server static binary (go.mod pins go 1.26)
|
||||
# Stage 2 — the API Server static binary (go.mod pins go 1.26)
|
||||
# =============================================================================
|
||||
FROM golang:1.26-alpine AS api-build
|
||||
WORKDIR /src
|
||||
@@ -38,113 +49,172 @@ RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \
|
||||
-o /out/api-server ./cmd/server
|
||||
|
||||
# =============================================================================
|
||||
# Stage 3 — build the Web App's embedded Vue UI (-> web/)
|
||||
# Stage 3 — the Web App's Vue UI (Web App/web -> /server/dist)
|
||||
# =============================================================================
|
||||
FROM node:22-alpine AS ui
|
||||
WORKDIR /ui
|
||||
COPY ["Web App/ui/package.json", "Web App/ui/package-lock.json", "./"]
|
||||
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/ui/", "./"]
|
||||
COPY ["Web App/web/", "./"]
|
||||
# vite.config.js writes the build to ../server/dist.
|
||||
RUN npm run build
|
||||
|
||||
# =============================================================================
|
||||
# Stage 4 — build the Web App static binary (go.mod pins go 1.24)
|
||||
# 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/go.mod", "Web App/go.sum", "./"]
|
||||
COPY ["Web App/server/go.mod", "Web App/server/go.sum", "./"]
|
||||
RUN go mod download
|
||||
COPY ["Web App/main.go", "Web App/bff.go", "./"]
|
||||
# Overlay the freshly built UI so //go:embed web picks it up.
|
||||
COPY --from=ui /web ./web
|
||||
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/dji-web-app .
|
||||
-o /out/web-app .
|
||||
|
||||
# =============================================================================
|
||||
# Stage 5 — fetch the PocketBase binary
|
||||
# Stage 5 — runtime: all three under supervisord
|
||||
# =============================================================================
|
||||
FROM alpine:latest AS pocketbase
|
||||
# Override with --build-arg PB_VERSION=x.y.z / PB_ARCH=arm64 as needed.
|
||||
ARG PB_VERSION=0.22.21
|
||||
ARG PB_ARCH=amd64
|
||||
RUN apk add --no-cache unzip wget ca-certificates \
|
||||
&& wget -O /tmp/pb.zip \
|
||||
"https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_${PB_ARCH}.zip" \
|
||||
&& unzip /tmp/pb.zip -d /pb \
|
||||
&& rm /tmp/pb.zip
|
||||
FROM alpine:3.24
|
||||
|
||||
# =============================================================================
|
||||
# Stage 6 — runtime: alpine:latest running all three under supervisord
|
||||
# =============================================================================
|
||||
FROM alpine:latest
|
||||
RUN apk add --no-cache ca-certificates tzdata supervisor
|
||||
# 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"
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=api-build /out/api-server ./api-server
|
||||
COPY --from=web-build /out/dji-web-app ./dji-web-app
|
||||
COPY --from=pocketbase /pb/pocketbase ./pocketbase
|
||||
# JS migrations (schema + seed accounts) applied by PocketBase on first serve.
|
||||
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/"]
|
||||
|
||||
# --- Runtime configuration (loopback-wired between the three services) ---------
|
||||
# API Server reads API_ADDR / POCKETBASE_URL / CORS_ALLOW_ORIGINS / POCKETBASE_ADMIN_*
|
||||
# Web App reads ADDR / API_BASE
|
||||
# NOTE: these bundle default credentials for convenience — override at `docker run`.
|
||||
ENV API_ADDR=":8080" \
|
||||
POCKETBASE_URL="http://127.0.0.1:8070" \
|
||||
CORS_ALLOW_ORIGINS="*" \
|
||||
POCKETBASE_ADMIN_EMAIL="admin@dji.local" \
|
||||
POCKETBASE_ADMIN_PASSWORD="djiadmin2026!" \
|
||||
ADDR=":8090" \
|
||||
API_BASE="http://127.0.0.1:8080"
|
||||
# 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
|
||||
|
||||
# --- supervisord: PocketBase first, then API Server, then Web App --------------
|
||||
RUN cat > /etc/supervisord.conf <<'EOF'
|
||||
# supervisord runs the three 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: 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
|
||||
pidfile=/run/supervisord.pid
|
||||
|
||||
; PocketBase: upsert the superuser (idempotent), then serve with the bundled
|
||||
; migrations. Runs as the unprivileged app user, which owns /pb/pb_data.
|
||||
[program:pocketbase]
|
||||
directory=/app
|
||||
user=app
|
||||
command=/bin/sh -c '/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
|
||||
directory=/pb
|
||||
# Ensure the service-account superuser exists, then serve on the internal port.
|
||||
command=/bin/sh -c "/app/pocketbase superuser upsert \"$POCKETBASE_ADMIN_EMAIL\" \"$POCKETBASE_ADMIN_PASSWORD\" --dir=/pb/pb_data ; exec /app/pocketbase serve --http=0.0.0.0:8070 --dir=/pb/pb_data --migrationsDir=/pb/pb_migrations"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=3
|
||||
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. 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
|
||||
directory=/app
|
||||
command=/app/api-server
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=3
|
||||
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]
|
||||
priority=30
|
||||
directory=/app
|
||||
command=/app/dji-web-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
|
||||
startsecs=3
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
EOF
|
||||
SUPERVISOR
|
||||
|
||||
# PocketBase data (SQLite). Mount a volume here to persist across restarts.
|
||||
VOLUME ["/pb/pb_data"]
|
||||
# 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; 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.
|
||||
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
|
||||
|
||||
# Required at runtime (no safe defaults): POCKETBASE_ADMIN_EMAIL,
|
||||
# POCKETBASE_ADMIN_PASSWORD. Pass them with `docker run -e ...`.
|
||||
|
||||
# Two volumes. /pb/pb_data: the database, the uploaded document blobs and
|
||||
# PocketBase's own backups. /app/data: the API Server's plugins.json. Both
|
||||
# pre-created and owned by app so a fresh named volume inherits that ownership.
|
||||
RUN mkdir -p /pb/pb_data /app/data && chown -R app:app /pb /app
|
||||
VOLUME ["/pb/pb_data", "/app/data"]
|
||||
WORKDIR /app
|
||||
# 8090 = Web App, 8080 = API Server + embedded panel, 8070 = PocketBase admin.
|
||||
EXPOSE 8090 8080 8070
|
||||
|
||||
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
|
||||
# All three processes 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 first-boot migrations on a cold database.
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
|
||||
CMD 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"]
|
||||
Reference in new issue
Block a user