Files
zhuiguang-ai/scripts/entrypoint-app.sh
T

38 lines
1.2 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# =============================================================================
# 追光AI APP 容器启动入口
# - 校验 .env
# - 跑 prisma migrate deploy(生产环境,安全前向迁移)
# - 启动 next start
# =============================================================================
set -e
cd /app
# Seed data volume if empty
if [ ! -f /app/data/bot-characters.json ] && [ -d /app/data-seed ]; then
echo "[entrypoint] Seeding data volume..."
cp -r /app/data-seed/* /app/data/
fi
# 1) .env 校验
if [ ! -f /app/.env ]; then
echo "[entrypoint-app] FATAL: /app/.env not found. Mount .env file into container."
exit 1
fi
# 让 .env 对 next start 可见(Next.js 14 在 production 下也会读 .env)
set -a
. /app/.env
set +a
# 2) 跑迁移(幂等;不阻塞启动)
echo "[entrypoint-app] Running prisma migrate deploy..."
npx prisma migrate deploy --schema=prisma/schema.prisma 2>&1 | tail -20 || {
echo "[entrypoint-app] WARN: migrate failed, continuing (DB schema may be ahead of migrations)"
}
# 3) 启动 Next.js
echo "[entrypoint-app] Starting next start on port ${PORT:-8301}..."
exec node_modules/.bin/next start --port ${PORT:-8301} --hostname 0.0.0.0