fix: container permissions and volume setup

Problems fixed:
- archivum user (UID 1000) could not write to bind-mounted /config or /data
  because Docker (especially on Windows/WSL2) creates volumes owned by root
- /data/wiki and /data/db subdirectories were never created, causing
  "no such file or directory" when the app tried to write files

Changes:
- docker/entrypoint.sh: runs as root, creates /config /data/wiki /data/db,
  chowns them to PUID:PGID, then drops privileges via su-exec
- Dockerfile: install su-exec + git, copy entrypoint, remove build-time
  USER directive (privilege drop happens at runtime via entrypoint)
- docker-compose.yml: switch local dev to named volumes so Docker manages
  ownership automatically (avoids Windows/WSL2 bind-mount permission issues);
  add TZ env var; explicit comments on how to switch to bind mounts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 14:38:23 +02:00
parent 37056ff8a4
commit 65aefb47ed
3 changed files with 71 additions and 17 deletions

28
docker/entrypoint.sh Normal file
View File

@@ -0,0 +1,28 @@
#!/bin/sh
# Archivum container entrypoint
# Runs as root, creates directories, fixes permissions, then drops to PUID:PGID.
set -e
PUID="${PUID:-1000}"
PGID="${PGID:-1000}"
echo "[entrypoint] starting as uid=$(id -u) gid=$(id -g)"
echo "[entrypoint] target PUID=${PUID} PGID=${PGID}"
# ── Ensure required directories exist ──────────────────────────────────────
mkdir -p /config
mkdir -p /data/wiki
mkdir -p /data/db
# ── Fix ownership so the app user can read/write all volumes ───────────────
# This is needed because:
# - bind-mounted directories from the host may be owned by root
# - Docker Desktop on Windows mounts volumes with host permissions
# that don't map to the container user
chown -R "${PUID}:${PGID}" /config /data
echo "[entrypoint] /config and /data ownership set to ${PUID}:${PGID}"
# ── Drop privileges and exec the application ───────────────────────────────
echo "[entrypoint] exec archivum as ${PUID}:${PGID}"
exec su-exec "${PUID}:${PGID}" /usr/local/bin/archivum "$@"