Skip to content

Commit a789bac

Browse files
authored
Merge pull request #7 from YuJunZhiXue/trae
修改docker和添加图片生成功能
2 parents 7887c03 + 88872c8 commit a789bac

12 files changed

Lines changed: 681 additions & 390 deletions

File tree

.env.example

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ADMIN_KEY=change-me-now
2+
PORT=7860
3+
WORKERS=1
4+
ENGINE_MODE=hybrid
5+
BROWSER_POOL_SIZE=2
6+
MAX_INFLIGHT=1
7+
ACCOUNT_MIN_INTERVAL_MS=1200
8+
REQUEST_JITTER_MIN_MS=120
9+
REQUEST_JITTER_MAX_MS=360
10+
MAX_RETRIES=2
11+
TOOL_MAX_RETRIES=2
12+
EMPTY_RESPONSE_RETRIES=1
13+
RATE_LIMIT_BASE_COOLDOWN=600
14+
RATE_LIMIT_MAX_COOLDOWN=3600
15+
STREAM_KEEPALIVE_INTERVAL=5
16+
ACCOUNTS_FILE=/workspace/data/accounts.json
17+
USERS_FILE=/workspace/data/users.json
18+
CAPTURES_FILE=/workspace/data/captures.json
19+
CONFIG_FILE=/workspace/data/config.json

.github/workflows/docker-publish.yml

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,15 @@ name: Docker Build and Push
22

33
on:
44
push:
5-
branches: [ "main", "master" ]
6-
# 当你打标签(比如发布 v1.0.0)时也会触发
5+
branches: [ "main" ]
76
tags: [ 'v*.*.*' ]
8-
pull_request:
9-
branches: [ "main", "master" ]
10-
11-
env:
12-
# 使用 GitHub 自带的镜像仓库,完全不需要注册第三方账号
13-
REGISTRY: ghcr.io
14-
# 自动读取你的 GitHub 用户名和仓库名作为镜像名
15-
IMAGE_NAME: ${{ github.repository }}
167

178
jobs:
189
build-and-push:
1910
runs-on: ubuntu-latest
20-
21-
# 这一步非常关键:赋予 GitHub Actions 推送镜像的权限
22-
permissions:
23-
contents: read
24-
packages: write
2511

2612
steps:
27-
- name: Checkout repository
13+
- name: Checkout
2814
uses: actions/checkout@v4
2915

3016
- name: Set up QEMU
@@ -33,34 +19,28 @@ jobs:
3319
- name: Set up Docker Buildx
3420
uses: docker/setup-buildx-action@v3
3521

36-
# 使用 GitHub 自带的 Token 自动登录,无需你手动配置任何密码
37-
- name: Log in to the Container registry
38-
if: github.event_name != 'pull_request'
22+
- name: Log in to Docker Hub
3923
uses: docker/login-action@v3
4024
with:
41-
registry: ${{ env.REGISTRY }}
42-
username: ${{ github.actor }}
43-
password: ${{ secrets.GITHUB_TOKEN }}
25+
username: ${{ secrets.DOCKERHUB_USERNAME }}
26+
password: ${{ secrets.DOCKERHUB_TOKEN }}
4427

45-
# 自动生成镜像标签 (例如 latest, v1.0.0)
46-
- name: Extract Docker metadata
28+
- name: Extract metadata
4729
id: meta
4830
uses: docker/metadata-action@v5
4931
with:
50-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
32+
images: yujunzhixue/qwen2api
5133
tags: |
5234
type=raw,value=latest,enable={{is_default_branch}}
5335
type=semver,pattern={{version}}
5436
type=sha,format=short
5537
56-
# 构建并推送镜像
57-
- name: Build and push Docker image
38+
- name: Build and push
5839
uses: docker/build-push-action@v5
5940
with:
6041
context: .
61-
push: ${{ github.event_name != 'pull_request' }}
42+
push: true
6243
tags: ${{ steps.meta.outputs.tags }}
6344
labels: ${{ steps.meta.outputs.labels }}
64-
# 开启构建缓存,加快以后每次打包的速度
6545
cache-from: type=gha
6646
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ COPY frontend/ ./
77
RUN npm run build
88

99
# Stage 2: Backend + Final Image
10-
FROM python:3.10-slim
10+
FROM python:3.11-slim
1111
WORKDIR /workspace
1212

13-
# Install system dependencies required for headless Firefox (Camoufox)
14-
RUN apt-get update && apt-get install -y --no-install-recommends \
13+
# Always refresh apt cache first (never cache this layer)
14+
RUN apt-get update
15+
16+
# Install system dependencies for headless Firefox (Camoufox)
17+
# Use || true on packages that may differ across Debian versions
18+
RUN apt-get install -y --no-install-recommends \
1519
wget \
1620
curl \
1721
ca-certificates \
18-
libx11-xcb1 \
1922
libx11-6 \
2023
libxcb1 \
2124
libxrandr2 \
@@ -24,12 +27,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2427
libxfixes3 \
2528
libxext6 \
2629
libxkbcommon0 \
27-
libdbus-glib-1-2 \
2830
libdbus-1-3 \
29-
libxt6 \
3031
libgtk-3-0 \
31-
libasound2 \
32-
libpulse0 \
3332
libdrm2 \
3433
libgbm1 \
3534
libxshmfence1 \
@@ -41,7 +40,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4140
libnspr4 \
4241
libglib2.0-0 \
4342
fonts-liberation \
44-
fonts-noto-cjk \
43+
&& apt-get install -y --no-install-recommends fonts-noto-cjk || true \
44+
&& apt-get install -y --no-install-recommends libdbus-glib-1-2 || true \
45+
&& apt-get install -y --no-install-recommends libasound2 libasound2t64 || true \
46+
&& apt-get install -y --no-install-recommends libpulse0 || true \
47+
&& apt-get install -y --no-install-recommends libx11-xcb1 || true \
4548
&& rm -rf /var/lib/apt/lists/*
4649

4750
ENV PYTHONIOENCODING=utf-8
@@ -58,7 +61,7 @@ COPY backend/ ./backend/
5861
COPY start.py ./
5962
COPY --from=frontend-builder /app/dist ./frontend/dist
6063

61-
# Create data directory
64+
# Create data and logs directories
6265
RUN mkdir -p /workspace/data /workspace/logs
6366

6467
EXPOSE 7860

0 commit comments

Comments
 (0)