58 lines
1.7 KiB
Bash
58 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
APP_ROOT="/opt/dukang-haoke"
|
|
DEPLOY_DIR="$APP_ROOT/deploy"
|
|
|
|
echo "==> install api deps only"
|
|
cd "$APP_ROOT"
|
|
export NODE_OPTIONS="--max-old-space-size=1024"
|
|
pnpm install --filter @dukang/api... --filter @dukang/domain --filter @dukang/shared-types
|
|
|
|
echo "==> env"
|
|
cat > "$APP_ROOT/server/dukang-api/.env.production" <<'ENV'
|
|
DATABASE_URL="mysql://dukang:Dukang2026!@localhost:3306/dukang_haoke"
|
|
REDIS_URL="redis://localhost:6379"
|
|
JWT_SECRET="gky4CNZgwdrYoDIDy4AWBiJRa4WX2ax8STe3TEG93Ht"
|
|
JWT_EXPIRES_IN="7d"
|
|
PORT=8090
|
|
MOCK_SMS=true
|
|
MOCK_SMS_CODE=123456
|
|
MOCK_PAY=true
|
|
MOCK_DELIVERY_AUTO=true
|
|
AUTO_APPROVE_STORE=true
|
|
ENV
|
|
|
|
echo "==> prisma"
|
|
cd "$APP_ROOT/server/dukang-api"
|
|
pnpm prisma:generate
|
|
npx prisma db push --accept-data-loss
|
|
pnpm prisma:seed
|
|
|
|
echo "==> serve"
|
|
npm install -g serve
|
|
|
|
echo "==> pm2"
|
|
mkdir -p /var/log/nginx/dukang /var/www/certbot
|
|
pm2 delete dukang-api dukang-h5-user dukang-h5-shop dukang-h5-partner 2>/dev/null || true
|
|
pm2 start "$DEPLOY_DIR/ecosystem.config.cjs"
|
|
pm2 save
|
|
|
|
echo "==> ssl"
|
|
if [ ! -f /etc/letsencrypt/live/user.ai-mirror.xyz/fullchain.pem ]; then
|
|
certbot certonly --webroot -w /var/www/certbot \
|
|
-d user.ai-mirror.xyz -d shop.ai-mirror.xyz -d partner.ai-mirror.xyz \
|
|
--non-interactive --agree-tos -m admin@ai-mirror.xyz
|
|
fi
|
|
|
|
echo "==> nginx"
|
|
cp "$DEPLOY_DIR/nginx-ai-mirror.conf" /etc/nginx/conf.d/dukang-ai-mirror.conf
|
|
nginx -t
|
|
systemctl reload nginx
|
|
|
|
echo "==> DONE"
|
|
pm2 list
|
|
ss -tlnp | grep -E '809[0-3]' || true
|
|
curl -s -o /dev/null -w "user:%{http_code}\n" http://127.0.0.1:8091/
|
|
curl -s -o /dev/null -w "api:%{http_code}\n" http://127.0.0.1:8090/api/v1/health 2>/dev/null || curl -s -o /dev/null -w "api:%{http_code}\n" http://127.0.0.1:8090/
|