#!/bin/sh set -e echo "[entrypoint] waiting for database..." node <<'NODE' const { Pool } = require('pg'); const url = process.env.DATABASE_URL; if (!url) { console.error('DATABASE_URL is required'); process.exit(1); } (async () => { for (let i = 0; i < 60; i++) { const pool = new Pool({ connectionString: url }); try { await pool.query('SELECT 1'); await pool.end(); process.exit(0); } catch { await pool.end().catch(() => undefined); await new Promise((r) => setTimeout(r, 2000)); } } console.error('database not ready after 120s'); process.exit(1); })(); NODE # 默认不灌演示/E2E 测试数据(migrate.js 判断值是否 === '1')。 # 如需在本地/演示环境灌数据,显式设置 SKIP_DEMO_SEED=0 SKIP_E2E_SEED=0 覆盖。 export SKIP_DEMO_SEED="${SKIP_DEMO_SEED:-1}" export SKIP_E2E_SEED="${SKIP_E2E_SEED:-1}" echo "[entrypoint] running migrations..." node dist/migrate.js echo "[entrypoint] starting API..." exec "$@"