Add local-network deployment automation and tighten runtime defaults
test / pytest (push) Successful in 35s
docker-image / build-and-push (push) Successful in 4m8s

This commit adds the first complete local-network deployment path for the project. It normalizes the runtime contract around a fixed container listener on 0.0.0.0:10000, binds the published compose port to 127.0.0.1, and keeps the image/build workflow aligned with the released container image.

It also introduces an installation script, an nginx reverse-proxy template, and a safer SQLite backup flow based on sqlite3 .backup with retention and optional rclone upload support. Deployment-oriented configuration has been consolidated into .env.example, repository-local .env files are now ignored, and the deployment scripts are executable.

In addition, the frontend mixed-content issue is fixed by switching the stylesheet reference to a root-relative static path, with tests updated to cover the regression. README guidance has been expanded to document the new install, nginx, backup, and restore conventions.
This commit is contained in:
2026-04-21 22:39:47 +02:00
parent eb29f03b74
commit 49a5452141
11 changed files with 414 additions and 66 deletions
+17 -11
View File
@@ -5,33 +5,39 @@ PROJECT_ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$PROJECT_ROOT"
if [ ! -f ".env" ] && [ -f ".env.example" ]; then
echo "未找到 .env,先从 .env.example 复制一份:"
echo ".env not found. Create it first from .env.example:"
echo " cp .env.example .env"
exit 1
fi
DATA_DIR_VALUE=$(grep '^DATA_DIR=' .env 2>/dev/null | tail -n 1 | cut -d '=' -f 2- || true)
DATA_DIR=${DATA_DIR_VALUE:-./data}
set -a
. ./.env
set +a
DATA_DIR=${DATA_DIR:-./data}
APP_PORT=${APP_PORT:-10000}
mkdir -p "$DATA_DIR"
echo "[1/4] 拉取最新代码(如果当前目录是 git 仓库)"
echo "[1/4] Pull latest code if this directory is a git repository"
if [ -d ".git" ]; then
git pull --ff-only
else
echo "跳过:当前目录不是 git 仓库"
echo "Skipped: current directory is not a git repository"
fi
echo "[2/4] 构建并更新容器"
docker compose up -d --build
echo "[2/4] Pull and update containers"
docker compose pull web
docker compose up -d
echo "[3/4] 当前容器状态"
echo "[3/4] Current container status"
docker compose ps
echo "[4/4] 最近日志"
echo "[4/4] Recent logs"
docker compose logs --tail=50 web
echo
echo "部署完成。应用默认地址:"
echo " http://localhost:$(grep '^PORT=' .env 2>/dev/null | tail -n 1 | cut -d '=' -f 2- || echo 10000)"
echo "Deployment complete. Default application URLs:"
echo " https://${HOST_DOMAIN:-localhost}"
echo " Backend port mapping: localhost:$APP_PORT -> container:10000"