bdc8e6d82a
- runner 不再 host 模式跑 docker build(原 host runner 缺 node/docker 无法执行) - 新流程:runner 打包源码 → scp 到 132 → 132 上 docker build + compose up - runner 只需 catthehacker 镜像(node/git/sshpass),docker 能力下沉到 132 - deploy/README 补 runner docker 模式部署命令(挂 sock + 持久化 /data) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
部署说明
拓扑
push/merge main ─▶ Gitea(192.168.100.125:3000)
│ 触发 .gitea/workflows/deploy.yml
▼
act_runner(192.168.100.128, docker 模式)
│ 打包源码 → scp
▼
部署机(192.168.100.132) /home/workspace/sundynix-site
│ docker build → compose up → 容器 :8090
│ │ 连
│ MySQL(192.168.100.127:3307)
▼
内网穿透 ──▶ 公网服务器 nginx ──▶ https://site.sundynix.cn
一次性准备
1. Gitea 仓库 Secrets(仓库 → Settings → Actions → Secrets)
| Secret | 值 |
|---|---|
DEPLOY_HOST |
192.168.100.132 |
DEPLOY_USER |
root |
DEPLOY_PASSWORD |
sundynix |
2. 部署机 132 准备
# 装好 docker + compose 插件后:
mkdir -p /home/workspace/sundynix-site
cd /home/workspace/sundynix-site
# 放置生产配置(参考仓库 .env.production.example)
vi .env # 改 admin 密码、JWT 密钥
.env 关键项见 .env.production.example。数据库指向内网 192.168.100.127:3307/sundynix_site(库不存在会自动建表 + 种子)。
3. act_runner 128 要求(docker 模式,非 host)
runner 必须用 docker 模式 + 挂 docker.sock + 持久化 /data,标签用带 node 的镜像:
docker run -d --name act_runner --restart unless-stopped \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /root/act_runner_data:/data \
-e GITEA_INSTANCE_URL=http://192.168.100.125:3000 \
-e GITEA_RUNNER_REGISTRATION_TOKEN=<在 gitea 运行器页创建新运行器获取> \
-e GITEA_RUNNER_NAME=Auto-CICD \
-e "GITEA_RUNNER_LABELS=ubuntu-latest:docker://catthehacker/ubuntu:act-22.04" \
gitea/act_runner:0.6.1
- job 在 catthehacker 镜像里跑(含 node/git/apt,checkout 与 sshpass 可用)
- 真正的
docker build在 132 上执行,128 只需能 ssh 到 132 - 部署机 132 需装 docker + compose 插件
4. 公网服务器 nginx
- 内网穿透把 132:8090 映射到公网机本地端口
- 用 nginx-site.sundynix.cn.conf 配置反代,改
upstream为穿透实际端口 - 证书:
certbot certonly --webroot -w /var/www/certbot -d site.sundynix.cn
日常
- 提交或合并到
main分支自动构建部署;也可在 Gitea Actions 页手动workflow_dispatch - 日常开发在
dev分支,PR 合并进main才触发上线 - 回滚:132 上
docker tag保留的旧镜像,或重跑上一次成功的 commit - 查日志:
docker logs -f sundynix-site - 本地手动出包(不走 CI):仓库根
docker build -t sundynix-site:latest .