修复启动脚本

This commit is contained in:
丹尼尔
2026-03-11 11:17:46 +08:00
parent 4a658a7331
commit 501153a081
3 changed files with 55 additions and 39 deletions

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# 生产部署脚本:启动前拉取最新代码 → 构建镜像 → 停止旧容器 → 启动新容器
set -e
@@ -8,6 +9,14 @@ PORT="${PORT:-3000}"
# 数据目录挂载到宿主机防止容器删除后丢失SQLite 库 wechat.db 及表数据)
HOST_DATA_DIR="${HOST_DATA_DIR:-$(pwd)/data}"
# 启动前自动获取最新代码(与远端 master 一致,丢弃本地修改)
if git rev-parse --git-dir >/dev/null 2>&1; then
echo "Fetching and reset to origin/master..."
git fetch --all && git reset --hard origin/master
else
echo "Not a git repo, skip git fetch/reset."
fi
echo "Building Docker image: ${IMAGE_NAME}..."
docker build -t "${IMAGE_NAME}" .