e329d3398a
Add FastAPI/React app with Docker deployment, Ubuntu one-click install, and docs for junior/senior high score tracking and mistake bank. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
749 B
Bash
30 lines
749 B
Bash
#!/usr/bin/env bash
|
|
#
|
|
# 更新已部署实例:拉取代码并重建容器
|
|
# 版权所有 (c) 马建军
|
|
#
|
|
set -euo pipefail
|
|
|
|
INSTALL_DIR="${INSTALL_DIR:-/opt/secondary-school-grade-archive}"
|
|
BRANCH="${BRANCH:-main}"
|
|
|
|
GREEN='\033[0;32m'
|
|
NC='\033[0m'
|
|
log_info() { echo -e "${GREEN}[INFO]${NC} $*"; }
|
|
|
|
if [[ ! -d "${INSTALL_DIR}/.git" ]]; then
|
|
echo "未找到部署目录 ${INSTALL_DIR},请先运行 deploy/install.sh"
|
|
exit 1
|
|
fi
|
|
|
|
cd "${INSTALL_DIR}"
|
|
log_info "拉取最新代码…"
|
|
git fetch origin
|
|
git checkout "${BRANCH}" 2>/dev/null || true
|
|
git pull origin "${BRANCH}"
|
|
|
|
log_info "重建并重启服务…"
|
|
docker compose --env-file .env up -d --build
|
|
|
|
log_info "更新完成。访问端口见 .env 中 WEB_PORT"
|