Docker: S3 and SeaweedFS stacks, matching DriverVault

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>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-11-17 17:50:20 +01:00
1 parent bc41d8b128
commit 5be676fc97
26 files changed
+2557 -72

No files matched your search

+46
View File
@@ -20,6 +20,33 @@ type Config struct {
// 503 and the rest of the server is unaffected.
PocketBaseAdminEmail string
PocketBaseAdminPassword string
// PocketBase file storage. With S3Enabled set and the bucket fully
// described, the server points PocketBase's "Files storage" at this bucket
// on boot instead of the pb_data volume; left unset, uploads stay on disk
// exactly as they always have. Only record files (document blobs) move —
// PocketBase's own backups are deliberately not touched.
//
// S3Endpoint has no default: an in-stack SeaweedFS and one outside it are
// different addresses, and guessing either would be worse than not trying.
S3Enabled bool
S3Bucket string
S3Region string
S3Endpoint string
S3AccessKey string
S3Secret string
// S3ForcePathStyle keeps bucket names in the path rather than the hostname.
// True by default because that is what a self-hosted gateway serves —
// virtual-host style would need a DNS entry per bucket.
S3ForcePathStyle bool
}
// StorageConfigured reports whether S3 file storage has been fully specified.
// Anything less counts as "not asked for": a half-filled .env leaves uploads on
// the local volume rather than pointing PocketBase at a bucket it cannot reach.
func (c Config) StorageConfigured() bool {
return c.S3Enabled && c.S3Bucket != "" && c.S3Endpoint != "" &&
c.S3AccessKey != "" && c.S3Secret != ""
}
// EnvFile is the .env path (relative to the working directory) that Load reads
@@ -39,6 +66,13 @@ func Load() Config {
PluginsFile: getenv("PLUGINS_FILE", "plugins.json"),
PocketBaseAdminEmail: getenv("POCKETBASE_ADMIN_EMAIL", os.Getenv("PB_ADMIN_EMAIL")),
PocketBaseAdminPassword: getenv("POCKETBASE_ADMIN_PASSWORD", os.Getenv("PB_ADMIN_PASSWORD")),
S3Enabled: boolEnv("PB_S3_ENABLED", false),
S3Bucket: getenv("PB_S3_BUCKET", "pilotvault"),
S3Region: getenv("PB_S3_REGION", "us-east-1"),
S3Endpoint: strings.TrimRight(getenv("PB_S3_ENDPOINT", ""), "/"),
S3AccessKey: getenv("PB_S3_ACCESS_KEY", ""),
S3Secret: getenv("PB_S3_SECRET", ""),
S3ForcePathStyle: boolEnv("PB_S3_FORCE_PATH_STYLE", true),
}
return cfg
}
@@ -104,6 +138,18 @@ func getenv(key, def string) string {
return def
}
// boolEnv reads a boolean variable, accepting the usual spellings; anything
// unrecognised (or unset) falls back to def.
func boolEnv(key string, def bool) bool {
switch strings.ToLower(strings.TrimSpace(os.Getenv(key))) {
case "1", "true", "yes", "on":
return true
case "0", "false", "no", "off":
return false
}
return def
}
func splitCSV(s string) []string {
parts := strings.Split(s, ",")
out := make([]string, 0, len(parts))