Files
LFSpecs/scripts/deploy.sh
T

31 lines
760 B
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.
#!/usr/bin/env bash
# ECS 部署脚本:拉代码 -> 宿主构建 -> 容器重启
# 用法:在服务器上执行 bash scripts/deploy.sh
set -euo pipefail
cd "$(dirname "$0")/.."
# 服务器上的 Node 装在 /opt/node(系统未自带 Node)
export PATH=/opt/node/bin:$PATH
if [ ! -f .env ]; then
echo "缺少 .env,请先从 .env.example 复制并填写" >&2
exit 1
fi
echo "==> 同步代码"
git fetch --depth 1 origin main
git reset --hard origin/main
echo "==> 安装依赖"
pnpm install --frozen-lockfile
echo "==> 构建"
NODE_OPTIONS=--max-old-space-size=768 pnpm build
echo "==> 重启容器"
docker compose up -d --force-recreate
echo "==> 健康检查"
sleep 3
curl -fsS -o /dev/null -w 'http %{http_code}\n' http://127.0.0.1:3010/