ci: 用容器跑编译并部署到 9000 端口

This commit is contained in:
2026-10-29 14:35:24 +08:00
parent 5f30f264f7
commit 6ff2983f4b
5 changed files with 154 additions and 45 deletions

View File

@@ -156,11 +156,15 @@ Config variants:
`start.sh` env var toggles: `START_REDIS`, `START_RABBITMQ`, `START_BACKEND`, `START_WORKER`, `START_FRONTEND`, `STOP_DOCKER`
## CI
## CI/CD
GitHub Actions (`.github/workflows/ci.yml`) runs on PRs and pushes to `main`/`master`:
- Backend: Go 1.24.x — `go vet ./...` then `go test -race -count=1 ./...`
- Frontend: Node 22 — `npm ci` then `npm run build`
Gitea Actions (`.gitea/workflows/ci.yml`) runs on pushes to `main`/`master` and deploys to production in the same job. The runner label is `aliyun` — a **host-mode** runner on the Aliyun ECS, so steps execute directly on the host (`/opt/vloop`, Docker, rsync) rather than in a disposable container.
- Backend: `golang:1.24.5` container — `go vet ./...` then `go test -race -count=1 ./...`
- Frontend: `node:24-alpine` container — `npm ci` then `npm run build`
- Deploy: validates `/opt/vloop/.env`, `rsync`s the workspace to `/opt/vloop`, then `docker compose -f docker-compose.prod.yml up -d --build --wait`
Host prerequisites: Git ≥ 2.34.1, **Node.js 22** (JavaScript actions such as `actions/checkout@v4` look up `node` on PATH), Docker + Compose v2, `rsync`. Public entrypoint: `http://goanchor.top:9000` (`APP_PORT` overridable). There is no PR gate — a push to `main` deploys immediately.
## Testing