mirror of
https://github.com/Smile-QWQ/SubTracker.git
synced 2026-05-19 10:24:31 +08:00
- add TZ to API compose defaults and example env config - keep tzdata in the image without hardcoding a single timezone - apply the runtime TZ value from entrypoint so users can switch timezones cleanly # Conflicts: # apps/api/.env.example
31 lines
783 B
Bash
31 lines
783 B
Bash
#!/bin/sh
|
||
set -eu
|
||
|
||
APP_ROOT="/app"
|
||
SCHEMA_PATH="$APP_ROOT/apps/api/prisma/schema.prisma"
|
||
PRISMA_BIN="$APP_ROOT/node_modules/.bin/prisma"
|
||
|
||
mkdir -p "$APP_ROOT/data" "$APP_ROOT/apps/api/storage/logos"
|
||
|
||
if [ -n "${TZ:-}" ] && [ -f "/usr/share/zoneinfo/$TZ" ]; then
|
||
ln -sf "/usr/share/zoneinfo/$TZ" /etc/localtime
|
||
echo "$TZ" > /etc/timezone
|
||
fi
|
||
|
||
if [ "${SKIP_DB_PUSH:-false}" != "true" ]; then
|
||
if [ ! -x "$PRISMA_BIN" ]; then
|
||
echo "[api] 未找到 Prisma CLI:$PRISMA_BIN" >&2
|
||
exit 1
|
||
fi
|
||
|
||
if [ ! -f "$SCHEMA_PATH" ]; then
|
||
echo "[api] 未找到 Prisma schema:$SCHEMA_PATH" >&2
|
||
exit 1
|
||
fi
|
||
|
||
echo "[api] 正在检查并初始化数据库结构..."
|
||
"$PRISMA_BIN" db push --skip-generate --schema "$SCHEMA_PATH"
|
||
fi
|
||
|
||
exec node "$APP_ROOT/apps/api/dist/index.js"
|