fix: run init container as root so the install marker can be written

The tb-node image runs as the non-root "thingsboard" user (uid 799), but
the freshly created /data named volume is owned by root, so
"touch /data/.thingsboard-installed" failed with permission denied after
every successful install. Combined with "set -e" and "restart: on-failure",
the init container kept re-running the installer forever and the main
thingsboard service (gated on service_completed_successfully) never
started, leaving the domain returning 404.

Running the init service as root lets the marker be written so the init
completes and stays idempotent across redeploys. Also widened the main
service healthcheck start window (start_period 300s, retries 10) so the
slow first boot on modest VPS hardware is not marked unhealthy while
docker compose up --wait is in progress.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Mauricio Siu
2026-07-08 01:55:38 -06:00
parent 47a04f55a5
commit e60d713179

View File

@@ -25,12 +25,15 @@ services:
test: ["CMD-SHELL", "timeout 5 bash -c '</dev/tcp/127.0.0.1/8080'"]
interval: 30s
timeout: 10s
retries: 5
start_period: 120s
retries: 10
start_period: 300s
thingsboard-init:
image: thingsboard/tb-node:4.3.1.1
restart: on-failure
# The image runs as the non-root "thingsboard" user, which cannot write
# the install marker to the freshly created (root-owned) /data volume.
user: root
depends_on:
thingsboard-db:
condition: service_healthy