All checks were successful
continuous-integration/drone/push Build is passing
- 新增告警模块 (alerts): 告警规则配置与触发 - 新增成本管理模块 (cost): 成本统计与分析 - 新增配额模块 (quota): 配额管理与限制 - 新增微信模块 (wechat): 微信相关功能接口 - 新增缓存服务 (cache): Redis 缓存封装 - 新增请求日志中间件 (request_logger) - 新增异常处理和链路追踪中间件 - 更新 dashboard 前端展示 - 更新 SDK stats_client 功能
86 lines
2.8 KiB
YAML
86 lines
2.8 KiB
YAML
kind: pipeline
|
|
type: docker
|
|
name: build-and-deploy
|
|
|
|
trigger:
|
|
branch:
|
|
- main
|
|
- develop
|
|
event:
|
|
- push
|
|
|
|
steps:
|
|
# 构建后端镜像
|
|
- name: build-backend
|
|
image: docker:dind
|
|
volumes:
|
|
- name: docker-sock
|
|
path: /var/run/docker.sock
|
|
commands:
|
|
- docker build -t platform-backend:${DRONE_COMMIT_SHA:0:8} -f deploy/Dockerfile.backend .
|
|
- docker tag platform-backend:${DRONE_COMMIT_SHA:0:8} platform-backend:latest
|
|
|
|
# 构建前端镜像
|
|
- name: build-frontend
|
|
image: docker:dind
|
|
volumes:
|
|
- name: docker-sock
|
|
path: /var/run/docker.sock
|
|
commands:
|
|
- docker build -t platform-frontend:${DRONE_COMMIT_SHA:0:8} -f deploy/Dockerfile.frontend .
|
|
- docker tag platform-frontend:${DRONE_COMMIT_SHA:0:8} platform-frontend:latest
|
|
|
|
# 部署测试环境
|
|
- name: deploy-test
|
|
image: docker:dind
|
|
volumes:
|
|
- name: docker-sock
|
|
path: /var/run/docker.sock
|
|
environment:
|
|
DATABASE_URL:
|
|
from_secret: database_url
|
|
API_KEY:
|
|
from_secret: api_key
|
|
JWT_SECRET:
|
|
from_secret: jwt_secret
|
|
CONFIG_ENCRYPT_KEY:
|
|
from_secret: config_encrypt_key
|
|
commands:
|
|
- docker network create platform-network 2>/dev/null || true
|
|
- docker stop platform-backend-test platform-frontend-test || true
|
|
- docker rm platform-backend-test platform-frontend-test || true
|
|
- docker run -d --name platform-backend-test --network platform-network -p 8001:8000 --restart unless-stopped -e DATABASE_URL=$DATABASE_URL -e API_KEY=$API_KEY -e JWT_SECRET=$JWT_SECRET -e CONFIG_ENCRYPT_KEY=$CONFIG_ENCRYPT_KEY platform-backend:latest
|
|
- docker run -d --name platform-frontend-test --network platform-network -p 3003:80 --restart unless-stopped platform-frontend:latest
|
|
when:
|
|
branch:
|
|
- develop
|
|
|
|
# 部署生产环境
|
|
- name: deploy-prod
|
|
image: docker:dind
|
|
volumes:
|
|
- name: docker-sock
|
|
path: /var/run/docker.sock
|
|
environment:
|
|
DATABASE_URL:
|
|
from_secret: database_url
|
|
API_KEY:
|
|
from_secret: api_key
|
|
JWT_SECRET:
|
|
from_secret: jwt_secret
|
|
CONFIG_ENCRYPT_KEY:
|
|
from_secret: config_encrypt_key
|
|
commands:
|
|
- docker stop platform-backend-prod platform-frontend-prod || true
|
|
- docker rm platform-backend-prod platform-frontend-prod || true
|
|
- docker run -d --name platform-backend-prod -p 9001:8000 --restart unless-stopped -e DATABASE_URL=$DATABASE_URL -e API_KEY=$API_KEY -e JWT_SECRET=$JWT_SECRET -e CONFIG_ENCRYPT_KEY=$CONFIG_ENCRYPT_KEY platform-backend:latest
|
|
- docker run -d --name platform-frontend-prod -p 4003:80 --restart unless-stopped platform-frontend:latest
|
|
when:
|
|
branch:
|
|
- main
|
|
|
|
volumes:
|
|
- name: docker-sock
|
|
host:
|
|
path: /var/run/docker.sock
|