WangDL 07d6b889ef
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 10m2s
feat: Dockerfile + CI/CD deploy workflow + @prisma/client 移入 production deps
2026-05-09 19:05:48 +08:00

46 lines
1.2 KiB
YAML

name: Deploy API Server
on:
push:
branches: [main]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Docker image
run: docker build -t zhixi-api:latest .
- name: Stop old container
run: docker stop zhixi-api 2>/dev/null || true
- name: Remove old container
run: docker rm zhixi-api 2>/dev/null || true
- name: Start new container
run: |
docker run -d \
--name zhixi-api \
--network zhixi-net \
--restart unless-stopped \
-p 3001:3000 \
-e NODE_ENV=production \
-e PORT=3000 \
-e DATABASE_URL="mysql://zhixi_user:Zhixi@2026!App@mysql-zhixi:3306/zhixi" \
-e REDIS_HOST=redis-zhixi \
-e REDIS_PORT=6379 \
-e JWT_SECRET=98b1e7e377a40021ad7c46c55e467d2a218a89db7afc7c912780152ad64bdc45 \
-e AI_PROVIDER=mock \
-e ENABLE_SWAGGER=false \
zhixi-api:latest
- name: Wait for startup
run: sleep 5
- name: Health check
run: |
curl -f http://localhost:3001/health || (docker logs zhixi-api --tail 30 && exit 1)