Spaces:
Paused
Paused
justincnn commited on
Commit ·
629a8be
1
Parent(s): cbe30d3
Add Docker build workflow and compose configurations
Browse files- .github/workflows/docker-build.yml +60 -0
- docker-compose.prod.yml +58 -0
- docker-compose.yml +29 -0
.github/workflows/docker-build.yml
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Docker Build and Push
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- main
|
| 7 |
+
- master
|
| 8 |
+
tags:
|
| 9 |
+
- 'v*'
|
| 10 |
+
pull_request:
|
| 11 |
+
branches:
|
| 12 |
+
- main
|
| 13 |
+
- master
|
| 14 |
+
|
| 15 |
+
env:
|
| 16 |
+
DOCKER_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/zai-proxy
|
| 17 |
+
|
| 18 |
+
jobs:
|
| 19 |
+
build:
|
| 20 |
+
runs-on: ubuntu-latest
|
| 21 |
+
steps:
|
| 22 |
+
- name: Checkout
|
| 23 |
+
uses: actions/checkout@v4
|
| 24 |
+
|
| 25 |
+
- name: Set up QEMU
|
| 26 |
+
uses: docker/setup-qemu-action@v3
|
| 27 |
+
|
| 28 |
+
- name: Set up Docker Buildx
|
| 29 |
+
uses: docker/setup-buildx-action@v3
|
| 30 |
+
|
| 31 |
+
- name: Login to Docker Hub
|
| 32 |
+
if: github.event_name != 'pull_request'
|
| 33 |
+
uses: docker/login-action@v3
|
| 34 |
+
with:
|
| 35 |
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
| 36 |
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
| 37 |
+
|
| 38 |
+
- name: Docker meta
|
| 39 |
+
id: meta
|
| 40 |
+
uses: docker/metadata-action@v5
|
| 41 |
+
with:
|
| 42 |
+
images: ${{ env.DOCKER_IMAGE }}
|
| 43 |
+
tags: |
|
| 44 |
+
type=ref,event=branch
|
| 45 |
+
type=ref,event=pr
|
| 46 |
+
type=semver,pattern={{version}}
|
| 47 |
+
type=semver,pattern={{major}}.{{minor}}
|
| 48 |
+
type=semver,pattern={{major}}
|
| 49 |
+
type=raw,value=latest,enable={{is_default_branch}}
|
| 50 |
+
|
| 51 |
+
- name: Build and push
|
| 52 |
+
uses: docker/build-push-action@v5
|
| 53 |
+
with:
|
| 54 |
+
context: .
|
| 55 |
+
platforms: linux/amd64,linux/arm64
|
| 56 |
+
push: ${{ github.event_name != 'pull_request' }}
|
| 57 |
+
tags: ${{ steps.meta.outputs.tags }}
|
| 58 |
+
labels: ${{ steps.meta.outputs.labels }}
|
| 59 |
+
cache-from: type=gha
|
| 60 |
+
cache-to: type=gha,mode=max
|
docker-compose.prod.yml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
zai-proxy:
|
| 5 |
+
image: your-dockerhub-username/zai-proxy:latest
|
| 6 |
+
container_name: zai-proxy
|
| 7 |
+
restart: unless-stopped
|
| 8 |
+
ports:
|
| 9 |
+
- "8080:8080"
|
| 10 |
+
environment:
|
| 11 |
+
# 服务配置
|
| 12 |
+
- PORT=8080
|
| 13 |
+
- LOG_LEVEL=info
|
| 14 |
+
|
| 15 |
+
# 上游服务配置
|
| 16 |
+
- UPSTREAM_URL=https://api.anthropic.com
|
| 17 |
+
- UPSTREAM_API_KEY=${UPSTREAM_API_KEY}
|
| 18 |
+
|
| 19 |
+
# 认证配置(可选)
|
| 20 |
+
# - AUTH_TYPE=jwt
|
| 21 |
+
# - JWT_SECRET=${JWT_SECRET}
|
| 22 |
+
|
| 23 |
+
# 代理配置(可选)
|
| 24 |
+
# - HTTP_PROXY=http://proxy.example.com:8080
|
| 25 |
+
# - HTTPS_PROXY=http://proxy.example.com:8080
|
| 26 |
+
|
| 27 |
+
# 健康检查
|
| 28 |
+
healthcheck:
|
| 29 |
+
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/health"]
|
| 30 |
+
interval: 30s
|
| 31 |
+
timeout: 10s
|
| 32 |
+
retries: 3
|
| 33 |
+
start_period: 40s
|
| 34 |
+
|
| 35 |
+
# 资源限制
|
| 36 |
+
deploy:
|
| 37 |
+
resources:
|
| 38 |
+
limits:
|
| 39 |
+
cpus: '1'
|
| 40 |
+
memory: 512M
|
| 41 |
+
reservations:
|
| 42 |
+
cpus: '0.5'
|
| 43 |
+
memory: 256M
|
| 44 |
+
|
| 45 |
+
# 日志配置
|
| 46 |
+
logging:
|
| 47 |
+
driver: "json-file"
|
| 48 |
+
options:
|
| 49 |
+
max-size: "10m"
|
| 50 |
+
max-file: "3"
|
| 51 |
+
|
| 52 |
+
# 网络配置
|
| 53 |
+
networks:
|
| 54 |
+
- zai-network
|
| 55 |
+
|
| 56 |
+
networks:
|
| 57 |
+
zai-network:
|
| 58 |
+
driver: bridge
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
zai-proxy:
|
| 5 |
+
image: justinzm/zai-proxy:latest
|
| 6 |
+
container_name: zai-proxy
|
| 7 |
+
restart: unless-stopped
|
| 8 |
+
ports:
|
| 9 |
+
- "8000:8000"
|
| 10 |
+
environment:
|
| 11 |
+
- PORT=8000
|
| 12 |
+
- LOG_LEVEL=info
|
| 13 |
+
volumes:
|
| 14 |
+
# 如果需要使用代理池,取消注释下面这行并创建 proxies.txt 文件
|
| 15 |
+
# - ./proxies.txt:/app/proxies.txt:ro
|
| 16 |
+
# 如果需要持久化日志,取消注释下面这行
|
| 17 |
+
# - ./logs:/app/logs
|
| 18 |
+
networks:
|
| 19 |
+
- zai-network
|
| 20 |
+
healthcheck:
|
| 21 |
+
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8000/health"]
|
| 22 |
+
interval: 30s
|
| 23 |
+
timeout: 10s
|
| 24 |
+
retries: 3
|
| 25 |
+
start_period: 40s
|
| 26 |
+
|
| 27 |
+
networks:
|
| 28 |
+
zai-network:
|
| 29 |
+
driver: bridge
|