构建: 入口脚本 chown 数据目录后降权运行

绑定挂载/命名卷被 docker 以 root 自动创建时,容器非 root 用户
写不进 db(SQLITE_CANTOPEN)。改为 entrypoint 以 root 启动,
chown 数据目录到 OT_UID:OT_GID(默认 1000:1000)后 su-exec 降权,
compose 不再需要 user: 覆盖。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Sakurasan
2026-08-18 22:25:43 +08:00
co-authored by Claude
parent 5aa0be13dc
commit 8495694671
3 changed files with 20 additions and 6 deletions
+3 -2
View File
@@ -17,8 +17,6 @@ services:
restart: unless-stopped
ports:
- "${HOST_PORT:-8080}:8080"
# 以宿主用户运行,保证能写当前目录的 ./data 绑盘(默认 1000:1000,可用 OT_UID/OT_GID 覆盖)
user: "${OT_UID:-1000}:${OT_GID:-1000}"
environment:
OT_ENV: production
OT_PORT: 8080
@@ -29,6 +27,9 @@ services:
OT_MASTER_KEY: ${OT_MASTER_KEY:?请在 .env 中设置 OT_MASTER_KEY}
OT_ADMIN_PASSWORD: ${OT_ADMIN_PASSWORD:?请在 .env 中设置 OT_ADMIN_PASSWORD}
OT_JWT_SECRET: ${OT_JWT_SECRET:?请在 .env 中设置 OT_JWT_SECRET}
# 入口脚本据此 chown 数据目录并降权运行(默认 1000:1000)
OT_UID: "${OT_UID:-1000}"
OT_GID: "${OT_GID:-1000}"
volumes:
- ./data:/app/data
healthcheck: