From 8636d130a5336c6bf255ccacf14b427964da1a5a Mon Sep 17 00:00:00 2001 From: tajniak81 <13187254+tajniak81@users.noreply.github.com> Date: Sun, 22 Nov 2026 11:45:05 +0100 Subject: [PATCH] Add TB_DATA / TB_DATA_ROOT to choose depot storage The depot mount is now ${TB_DATA:-traildepot} (rootless) and ${TB_DATA_ROOT:-traildepot} (root). The default keeps the named volume; a host path (containing a "/") switches to a bind mount. Co-Authored-By: Claude Opus 5.5 --- .env.example | 11 +++++++++++ README.md | 6 +++++- docker-compose.root.yml | 3 ++- docker-compose.rootless.yml | 3 ++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 0486e0e..4d990bf 100644 --- a/.env.example +++ b/.env.example @@ -16,6 +16,17 @@ TB_PORT=4000 # Port for the root variant (only used with docker-compose.root.yml) TB_PORT_ROOT=4000 +# Where the depot (databases, config, uploads, secrets, backups) is stored. +# Either a Docker named volume (default `traildepot`, one per Compose project) +# or a host path for a bind mount — a path must contain a `/`, e.g. ./traildepot. +# With a bind mount the host folder must be writable by the container user +# (rootless) and hides the baked-in auth UI — see README › Data persistence. +TB_DATA=traildepot + +# Depot location for the root variant (only used with docker-compose.root.yml). +# Use a different host path than TB_DATA so the two stacks don't share a depot. +TB_DATA_ROOT=traildepot + # Public URL TrailBase is reached at (e.g. https://api.example.com). # Needed for valid links in auth emails and for OAuth redirects. Leave blank for local use. TB_PUBLIC_URL= diff --git a/README.md b/README.md index f4202d3..2131a50 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ Copy `.env.example` to `.env` and adjust. Compose reads `.env` automatically; ** | `CONTAINER_NAME` | `trailbase` | Base name for the container. | | `TB_PORT` | `4000` | Port for the rootless stack (used inside the container and for the host mapping). | | `TB_PORT_ROOT` | `4000` | Port for the root stack. | +| `TB_DATA` | `traildepot` | Depot storage for the rootless stack: a named volume (default) or a host path for a bind mount (must contain a `/`, e.g. `./traildepot`). | +| `TB_DATA_ROOT` | `traildepot` | Depot storage for the root stack. Use a different host path than `TB_DATA` so the stacks don't share a depot. | | `TB_PUBLIC_URL` | *(empty)* | Public URL of the instance, passed as `--public-url`. Needed for auth email links and OAuth redirects. | | `TB_ADMIN_EMAIL` | *(empty)* | Admin email to bootstrap. Leave blank to skip bootstrapping. | | `TB_ADMIN_PASSWORD` | *(empty)* | Admin password. Required only when the user doesn't yet exist. | @@ -120,7 +122,9 @@ Data survives container recreation. To develop migrations against the running in You can also bake `migrations` into the image by uncommenting the corresponding `COPY` line in the Dockerfile. -> **Note:** if you switch the named volume to a host bind mount (e.g. `./traildepot:/app/traildepot`) with the rootless image, make sure the host folder exists and is writable by the container user, or TrailBase fails with `PermissionDenied`. A bind mount also hides the auth UI component baked into the image; reinstall it with `trail components add trailbase/auth_ui`. +To keep the depot in a host folder instead, set `TB_DATA` (or `TB_DATA_ROOT` for the root stack) to a path, e.g. `TB_DATA=./traildepot`. Any value without a `/` is treated by Compose as a volume name, and only `traildepot` is declared, so use a path for anything else. + +> **Note:** if you switch the named volume to a host bind mount (e.g. `TB_DATA=./traildepot`) with the rootless image, make sure the host folder exists and is writable by the container user, or TrailBase fails with `PermissionDenied`. A bind mount also hides the auth UI component baked into the image; reinstall it with `trail components add trailbase/auth_ui`. ## Building for a specific version or architecture diff --git a/docker-compose.root.yml b/docker-compose.root.yml index c6084b2..db5d14c 100644 --- a/docker-compose.root.yml +++ b/docker-compose.root.yml @@ -29,7 +29,8 @@ services: - "${TB_PORT_ROOT:-4000}:${TB_PORT_ROOT:-4000}" volumes: # persist databases, config, uploads, secrets and backups - - traildepot:/app/traildepot + # TB_DATA_ROOT: named volume (default) or a host path such as ./traildepot-root (see .env) + - ${TB_DATA_ROOT:-traildepot}:/app/traildepot # uncomment to develop migrations against the running instance # - ./migrations:/app/traildepot/migrations healthcheck: diff --git a/docker-compose.rootless.yml b/docker-compose.rootless.yml index 633a58e..2f7bfdb 100644 --- a/docker-compose.rootless.yml +++ b/docker-compose.rootless.yml @@ -29,7 +29,8 @@ services: - "${TB_PORT:-4000}:${TB_PORT:-4000}" volumes: # persist databases, config, uploads, secrets and backups - - traildepot:/app/traildepot + # TB_DATA: named volume (default) or a host path such as ./traildepot (see .env) + - ${TB_DATA:-traildepot}:/app/traildepot # uncomment to develop migrations against the running instance # - ./migrations:/app/traildepot/migrations healthcheck: