#!/bin/sh # Docker entrypoint script # 修复挂载目录权限后以 nextjs 用户启动应用 # 创建必要的子目录(以 root 身份) mkdir -p /app/recycle/posts /app/recycle/meta /app/logs /app/backups # 修复 recycle 目录权限 chown -R nextjs:nodejs /app/recycle /app/logs /app/backups # 修复博客目录权限(让 nextjs 用户可写) if [ -d "/blog/content" ]; then chown -R nextjs:nodejs /blog/content fi if [ -d "/blog/static" ]; then chown -R nextjs:nodejs /blog/static fi if [ -d "/blog/.git" ]; then chown -R nextjs:nodejs /blog/.git fi if [ -f "/blog/hugo.toml" ]; then chown nextjs:nodejs /blog/hugo.toml fi # 配置 git(容器内 nextjs 用户) su-exec nextjs git config --global user.name "Write Server" 2>/dev/null su-exec nextjs git config --global user.email "write@usj.cc" 2>/dev/null su-exec nextjs git config --global --add safe.directory /blog 2>/dev/null # 以 nextjs 用户启动应用 exec su-exec nextjs "$@"