Plugins: drop the plugins.json migration, and the volume it needed
The project has no public installs, so there is nothing to migrate from. MigrateLegacyFile, the file-backed Store it read through, PLUGINS_FILE and the legacy path threaded through the Server all go. What is left is one store, PocketBase, and a plugins package that touches no filesystem at all. That was the last thing keeping api_data alive, so the volume goes too. All four compose files now declare exactly one volume, pb_data, and the standalone API Server compose declares none - it talks to an external PocketBase and has nothing of its own to keep. Backing up the stack is backing up one path again. Both images get simpler for it. The API Server image loses VOLUME /data and the su-exec entrypoint that existed only to fix a mounted volume's ownership, so it goes back to a plain USER app; its working directory is now /app and holds nothing. The AIO image loses its second volume and chowns only /pb/pb_data. One consequence worth stating plainly, because it is a small regression rather than a no-op. The panel's Settings -> PocketBase and Settings -> Web App screens write .env in the working directory, which is now ephemeral. In the multi-container stack that changes nothing: compose sets all five of those keys as container environment, and loadDotEnv only applies a key that is not already set, so the file could never win a restart there anyway. In the AIO image it did win for POCKETBASE_ADMIN_EMAIL/_PASSWORD, which are not in that container's environment - so a service account fixed from the panel now lasts only until the container is recreated. Both READMEs say so. Moving those two screens into the app_settings singleton would close it properly; the PocketBase URL and credentials cannot follow, since they are how the database is reached in the first place. go build, go vet and go test ./... pass; the compose files parse and each resolves to a single pb_data volume. Not verified: no Docker CLI here, so neither image was built. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
660af5736a
commit
ee4ac441be
@@ -47,9 +47,7 @@ API_PORT=8080
|
||||
# --- Storage -----------------------------------------------------------------
|
||||
# Defaults are Docker-managed named volumes. Set either to an absolute host path
|
||||
# for a bind mount, e.g. PB_DATA=/srv/drivervault/pb_data.
|
||||
# PB_DATA — the PocketBase database and uploads.
|
||||
# API_DATA — the .env the API Server panel writes back (plugin settings are in
|
||||
# the database, under PB_DATA)
|
||||
# when a superadmin retargets the PocketBase connection.
|
||||
# PB_DATA — the PocketBase database and uploads. It is the only volume in the
|
||||
# image: the API Server keeps no state on disk, so everything it owns (plugin
|
||||
# settings included) is backed up by backing up this one path.
|
||||
PB_DATA=pb_data
|
||||
API_DATA=api_data
|
||||
|
||||
+12
-15
@@ -16,7 +16,6 @@
|
||||
# -e DRIVERVAULT_SUPERADMIN_EMAIL=owner@example.com \
|
||||
# -e DRIVERVAULT_SUPERADMIN_PASSWORD=change-me \
|
||||
# -v drivervault_pb:/pb/pb_data \
|
||||
# -v drivervault_api:/data \
|
||||
# drivervault-aio
|
||||
#
|
||||
# Then: web app on http://host/ and PocketBase admin on http://host:8070/_/
|
||||
@@ -162,12 +161,11 @@ stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
|
||||
; API Server: wait for PocketBase to be healthy, then start. It runs from /data
|
||||
; because it writes the panel .env relative to its working directory, and /data
|
||||
; is the volume that keeps it across container recreates. (Plugin settings live
|
||||
; in PocketBase, under /pb/pb_data.)
|
||||
; API Server: wait for PocketBase to be healthy, then start. It keeps no state
|
||||
; on disk — plugin settings, like everything else it owns, live in PocketBase —
|
||||
; so its working directory is just a place to run from.
|
||||
[program:api-server]
|
||||
directory=/data
|
||||
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
|
||||
@@ -190,13 +188,13 @@ stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
SUPERVISOR
|
||||
|
||||
# The entrypoint stays root only long enough to make the two volumes writable by
|
||||
# the app user, then hands off to supervisord. The chown matters for volumes
|
||||
# created by an earlier build of this image, when both services ran as root.
|
||||
# The entrypoint stays root only long enough to make the data volume 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 /data; do
|
||||
for dir in /pb/pb_data; do
|
||||
mkdir -p "$dir"
|
||||
if [ "$(stat -c %U "$dir" 2>/dev/null)" != "app" ]; then
|
||||
echo "entrypoint: taking ownership of $dir"
|
||||
@@ -214,7 +212,6 @@ ENV API_ADDR=:8080 \
|
||||
POCKETBASE_URL=http://127.0.0.1:8070 \
|
||||
CORS_ALLOW_ORIGINS=http://localhost:8090 \
|
||||
AUTH_USERS_COLLECTION=users \
|
||||
PLUGINS_FILE=/data/plugins.json \
|
||||
WEBAPP_URL=http://127.0.0.1:80
|
||||
|
||||
# Required at runtime (no safe defaults): PB_ADMIN_EMAIL, PB_ADMIN_PASSWORD.
|
||||
@@ -229,12 +226,12 @@ ENV API_ADDR=:8080 \
|
||||
# base, or set OCPP_REQUIRE_TLS=false on a trusted network.
|
||||
# Pass them with `docker run -e ...`.
|
||||
|
||||
# pb_data holds the database — including the plugin settings; /data holds the
|
||||
# .env the panel rewrites when a superadmin retargets PocketBase. Both are
|
||||
# pb_data holds everything that persists — the database, the uploads, and the
|
||||
# server settings that used to sit in a file beside the binary. It is the only
|
||||
# volume: the API Server keeps no state on disk. Both directories are
|
||||
# pre-created and owned by app so a fresh named volume inherits that ownership.
|
||||
RUN mkdir -p /pb/pb_data /data && chown -R app:app /pb /data
|
||||
RUN mkdir -p /pb/pb_data /app && chown -R app:app /pb /app
|
||||
VOLUME /pb/pb_data
|
||||
VOLUME /data
|
||||
# 80 = Web App, 8070 = PocketBase admin, 8080 = API Server + embedded API panel
|
||||
# (also the /ocpp/{serial} endpoint chargers dial into).
|
||||
EXPOSE 80 8070 8080
|
||||
|
||||
+10
-4
@@ -76,11 +76,17 @@ Identical to the multi-container stack, and idempotent:
|
||||
|
||||
| Volume | Holds |
|
||||
|---|---|
|
||||
| `/pb/pb_data` | the PocketBase SQLite database and uploaded files |
|
||||
| `/data` | the `.env` the API Server panel rewrites when a superadmin retargets the PocketBase connection (plugin settings live in `/pb/pb_data`, with everything else) |
|
||||
| `/pb/pb_data` | the PocketBase SQLite database and uploaded files — everything that persists |
|
||||
|
||||
Both default to Docker-managed named volumes; set `PB_DATA` / `API_DATA` to
|
||||
absolute host paths in the prod file for bind mounts.
|
||||
One volume, because the API Server keeps no state on disk. Plugin enable-state
|
||||
and global config live in the database like the rest of the settings, so backing
|
||||
up this one path backs up the whole image. It defaults to a Docker-managed named
|
||||
volume; set `PB_DATA` to an absolute host path in the prod file for a bind mount.
|
||||
|
||||
> One thing does **not** persist: the API Server panel's *Settings → PocketBase*
|
||||
> and *Settings → Web App* screens apply immediately but only for the life of the
|
||||
> container. Set the corresponding environment variables to change them
|
||||
> permanently.
|
||||
|
||||
## Charger control (OCPP)
|
||||
|
||||
|
||||
@@ -48,11 +48,10 @@ services:
|
||||
- "${PB_PORT:-8070}:8070" # PocketBase admin UI / API
|
||||
- "${API_PORT:-8080}:8080" # API Server + panel (root /) + /ocpp/{serial}
|
||||
volumes:
|
||||
# Named volumes by default; set PB_DATA / API_DATA to host paths in .env
|
||||
# for bind mounts.
|
||||
# The only volume — named by default; set PB_DATA to a host path in .env
|
||||
# for a bind mount. The API Server keeps no state on disk, so everything
|
||||
# it owns (plugin settings included) is in here.
|
||||
- "${PB_DATA:-pb_data}:/pb/pb_data"
|
||||
# The .env the panel writes back; plugin settings live in the database.
|
||||
- "${API_DATA:-api_data}:/data"
|
||||
healthcheck:
|
||||
# All three processes must answer. Declared here as well as in the image so
|
||||
# the check is visible, and works against an older pulled image.
|
||||
@@ -64,4 +63,3 @@ services:
|
||||
|
||||
volumes:
|
||||
pb_data:
|
||||
api_data:
|
||||
|
||||
@@ -51,9 +51,9 @@ services:
|
||||
- "${PB_PORT:-8070}:8070" # PocketBase admin UI / API
|
||||
- "${API_PORT:-8080}:8080" # API Server + panel (root /) + /ocpp/{serial}
|
||||
volumes:
|
||||
# The only volume: the API Server keeps no state on disk, so everything
|
||||
# it owns — plugin settings included — lives in the database.
|
||||
- pb_data:/pb/pb_data
|
||||
# The .env the panel writes back; plugin settings live in the database.
|
||||
- api_data:/data
|
||||
healthcheck:
|
||||
# All three processes must answer. Declared here as well as in the image so
|
||||
# the check is visible, and works against an older pulled image.
|
||||
@@ -65,4 +65,3 @@ services:
|
||||
|
||||
volumes:
|
||||
pb_data:
|
||||
api_data:
|
||||
|
||||
Reference in New Issue
Block a user