加 git-sync 自动同步部署 compose

This commit is contained in:
bia
2026-06-08 16:53:10 +08:00
parent f5669dc01d
commit cd6cab33f1

View File

@ -0,0 +1,45 @@
# 极空间 Composestory 事件编辑器 + 自动 git 同步。
# 效果:本机 push 到 Gitea 后,约 1 分钟内 NAS 自动拉取最新前端,浏览器刷新即生效。
#
# 用法:极空间 Docker →「Compose / 项目」→ 新建 → 粘贴本文件 → 改下面标 ← 的 2~3 处 → 部署。
# 首次部署前:先停止并删除原来的单容器 story-event-web数据在 /data 目录,删容器不丢)。
services:
# ① 同步器:每 60s 把 Gitea 上的最新仓库强制同步到共享目录 /repo
story-gitsync:
image: alpine/git
container_name: story-gitsync
restart: unless-stopped
entrypoint: ["/bin/sh", "-c"]
command:
- >
git config --global --add safe.directory /repo;
cd /repo;
if [ ! -d .git ]; then
git init -q;
git remote add origin https://git.xindiegaming.top/bia/story-edit-web.git;
fi;
while true; do
git fetch -q origin main && git reset --hard -q origin/main;
sleep 60;
done
volumes:
# ← 共享目录:随便选个空目录给同步器用(不存在会自动建)。下面 story-web 要引用同一路径。
- "/SATA存储11/Docker/story-edit-web-src:/repo"
# ② 编辑器本体(沿用已导入的镜像 story-event-web:latest
story-web:
image: story-event-web:latest
container_name: story-event-web
restart: unless-stopped
depends_on: [story-gitsync]
ports:
- "8787:8787"
environment:
STORY_WEB_PASSWORD: "change-me" # ← 改成你的共享口令
TZ: "Asia/Shanghai"
volumes:
# ← 事件数据:填你原来单容器 /data 对应的 NAS 目录(务必填对,否则看不到旧数据)
- "/SATA存储11/Docker/story-event-web/data:/data"
# 前端静态:直接取自同步器拉下来的仓库子目录(只读)。这条按上面的共享路径,一般不用改。
- "/SATA存储11/Docker/story-edit-web-src/web/static:/app/web/static:ro"