fix: 使用entrypoint脚本自动修复挂载目录权限

- 容器以root启动,自动修复权限后切换到appuser运行
- 既保证安全性,又简化部署流程
- 无需手动chown目录
This commit is contained in:
2026-05-03 15:10:12 +08:00
parent 5682f6fbb0
commit 802fd7319e
3 changed files with 19 additions and 7 deletions
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
set -e
DATA_DIR="/app/data"
UPLOADS_DIR="/app/uploads"
mkdir -p "$DATA_DIR" "$UPLOADS_DIR"
if [ "$(id -u)" = "0" ]; then
chown -R appuser:appgroup "$DATA_DIR" "$UPLOADS_DIR"
exec su-exec appuser "$@"
else
exec "$@"
fi