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

View File

@@ -8,10 +8,28 @@ services:
restart: unless-stopped
ports:
- "8080:4000"
volumes:
- ${DOCKER_PATH:-./data}/config:/config
- ${DOCKER_PATH:-./data}/data:/data
environment:
# Points to the config directory inside the container.
DOCKER_PATH: /config
UI_DIR: /srv/archivum/ui
# Set to match the owner of the host directories (run `id` to check).
PUID: ${PUID:-1000}
PGID: ${PGID:-1000}
TZ: ${TZ:-Europe/Stockholm}
volumes:
# Configuration (config.json written here by Setup Wizard).
- archivum-config:/config
# All data: wiki files live in /data/wiki, SQLite db in /data/db.
# Using named volumes for local dev avoids Windows/WSL2 permission issues.
- archivum-data:/data
# Named volumes let Docker manage ownership automatically.
# Replace with bind mounts if you need direct host access:
# - ./local/config:/config
# - ./local/data:/data
# (and make sure the host directories are owned by PUID:PGID)
volumes:
archivum-config:
archivum-data: