Skip to content

Commit 2a0d3ab

Browse files
authored
Merge pull request #20 from wold9527/main
添加绑卡和实用功能
2 parents fa8f030 + b8a4161 commit 2a0d3ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+17414
-1545
lines changed

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@
1717

1818
# 远程 PostgreSQL(优先)
1919
# APP_DATABASE_URL=postgresql://user:password@host:5432/dbname
20+
21+
# ── 第三方自动绑卡(可选) ───────────────────────────────────
22+
# 第三方绑卡 API 地址(支持填 Workers 根域名,后端会自动补全路径)
23+
# BIND_CARD_API_URL=https://twilight-river-f148.482091502.workers.dev/
24+
25+
# 第三方绑卡 API Key(可留空,后端会先尝试无鉴权)
26+
# BIND_CARD_API_KEY=your_api_key_here

.github/workflows/docker-image.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "master", "main" ]
6+
tags: [ 'v*.*.*' ]
7+
pull_request:
8+
branches: [ "master", "main" ]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build-and-push-image:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
28+
- name: Log in to the Container registry
29+
if: github.event_name != 'pull_request'
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
# 修改这里:使用 GHCR_TOKEN 而不是 GITHUB_TOKEN
35+
password: ${{ secrets.GHCR_TOKEN }}
36+
37+
- name: Extract metadata (tags, labels) for Docker
38+
id: meta
39+
uses: docker/metadata-action@v5
40+
with:
41+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
42+
tags: |
43+
type=raw,value=latest
44+
type=ref,event=branch
45+
type=semver,pattern={{version}}
46+
type=semver,pattern={{major}}.{{minor}}
47+
type=semver,pattern={{major}}
48+
type=sha
49+
50+
51+
52+
53+
- name: Build and push Docker image
54+
uses: docker/build-push-action@v5
55+
with:
56+
context: .
57+
push: ${{ github.event_name != 'pull_request' }}
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}
60+
cache-from: type=gha
61+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
1010
# WebUI 默认配置
1111
WEBUI_HOST=0.0.0.0 \
1212
WEBUI_PORT=1455 \
13+
DISPLAY=:99 \
14+
ENABLE_VNC=1 \
15+
VNC_PORT=5900 \
16+
NOVNC_PORT=6080 \
1317
LOG_LEVEL=info \
1418
DEBUG=0
1519

@@ -19,18 +23,29 @@ RUN apt-get update \
1923
&& apt-get install -y --no-install-recommends \
2024
gcc \
2125
python3-dev \
26+
xvfb \
27+
fluxbox \
28+
x11vnc \
29+
websockify \
30+
novnc \
31+
ca-certificates \
2232
&& rm -rf /var/lib/apt/lists/*
2333

2434
# 复制依赖文件并安装
2535
COPY requirements.txt .
2636
RUN pip install --no-cache-dir --upgrade pip \
27-
&& pip install --no-cache-dir -r requirements.txt
37+
&& pip install --no-cache-dir -r requirements.txt \
38+
&& python -m playwright install --with-deps chromium
2839

2940
# 复制项目代码
3041
COPY . .
42+
COPY scripts/docker/start-webui.sh /app/scripts/docker/start-webui.sh
43+
RUN chmod +x /app/scripts/docker/start-webui.sh
3144

3245
# 暴露端口
3346
EXPOSE 1455
47+
EXPOSE 6080
48+
EXPOSE 5900
3449

3550
# 启动 WebUI
36-
CMD ["python", "webui.py"]
51+
CMD ["/app/scripts/docker/start-webui.sh"]

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88
[![Python](https://img.shields.io/badge/Python-3.10%2B-blue.svg)](https://www.python.org/)
99

1010
## QQ群
11-
- 交流群:291638849
12-
- https://qm.qq.com/q/ZTCKxawxeo
1311

14-
## Telegram交流频道
15-
- https://t.me/cysq2026
12+
- 交流群: https://qm.qq.com/q/ZTCKxawxeo
1613

1714
## 致谢
1815

@@ -129,13 +126,21 @@ codex-console.exe --access-password mypassword
129126
docker-compose up -d
130127
```
131128

132-
你可以在 `docker-compose.yml` 中修改环境变量,比如端口和访问密码。
129+
你可以在 `docker-compose.yml` 中修改环境变量,比如端口和访问密码。
130+
如果需要看“全自动绑卡”的可视化浏览器,打开:
131+
132+
- noVNC: `http://127.0.0.1:6080`
133133

134134
### 使用 docker run
135135

136136
```bash
137137
docker run -d \
138138
-p 1455:1455 \
139+
-p 6080:6080 \
140+
-e DISPLAY=:99 \
141+
-e ENABLE_VNC=1 \
142+
-e VNC_PORT=5900 \
143+
-e NOVNC_PORT=6080 \
139144
-e WEBUI_HOST=0.0.0.0 \
140145
-e WEBUI_PORT=1455 \
141146
-e WEBUI_ACCESS_PASSWORD=your_secure_password \

docker-compose.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@ version: '3.8'
33
services:
44
webui:
55
build: .
6+
shm_size: "1gb"
67
ports:
78
- "1455:1455"
9+
- "6080:6080"
10+
# 如需使用 VNC 客户端直连可打开:
11+
# - "5900:5900"
812
environment:
913
- WEBUI_HOST=0.0.0.0
1014
- WEBUI_PORT=1455
15+
- DISPLAY=:99
16+
- ENABLE_VNC=1
17+
- VNC_PORT=5900
18+
- NOVNC_PORT=6080
1119
- DEBUG=0
1220
- LOG_LEVEL=info
1321
# 如果需要访问密码,可以在这里取消注释并设置
@@ -16,4 +24,4 @@ services:
1624
# 挂载数据目录以持久化数据库和日志
1725
- ./data:/app/data
1826
- ./logs:/app/logs
19-
restart: unless-stopped
27+
restart: unless-stopped

make-test-win.bat

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@echo off
2+
setlocal
3+
cd /d "%~dp0"
4+
5+
set "PS_CMD="
6+
where powershell.exe >nul 2>nul
7+
if not errorlevel 1 set "PS_CMD=powershell.exe"
8+
if not defined PS_CMD (
9+
where pwsh.exe >nul 2>nul
10+
if not errorlevel 1 set "PS_CMD=pwsh.exe"
11+
)
12+
if not defined PS_CMD (
13+
echo.
14+
echo PowerShell not found. Install Windows PowerShell or PowerShell 7 first.
15+
exit /b 1
16+
)
17+
18+
%PS_CMD% -ExecutionPolicy Bypass -File ".\scripts\make_windows_test_bundle.ps1"
19+
if errorlevel 1 (
20+
echo.
21+
echo Failed to create test bundle.
22+
exit /b 1
23+
)
24+
25+
echo.
26+
echo Test bundle created successfully.
27+
echo You can run: ..\codex-console2-win-test\start-webui.bat

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ python-multipart>=0.0.6
1111
sqlalchemy>=2.0.0
1212
aiosqlite>=0.19.0
1313
psycopg[binary]>=3.1.18
14-
# 可选:无痕打开支付页需要 playwright(pip install playwright && playwright install chromium)
15-
# playwright>=1.40.0
14+
# 自动绑卡(local_auto)依赖
15+
playwright>=1.40.0

scripts/docker/start-webui.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
export DISPLAY="${DISPLAY:-:99}"
5+
ENABLE_VNC="${ENABLE_VNC:-1}"
6+
VNC_PORT="${VNC_PORT:-5900}"
7+
NOVNC_PORT="${NOVNC_PORT:-6080}"
8+
9+
if [[ "${ENABLE_VNC}" == "1" || "${ENABLE_VNC,,}" == "true" ]]; then
10+
echo "[docker] starting Xvfb on ${DISPLAY}"
11+
Xvfb "${DISPLAY}" -screen 0 1366x900x24 -ac +extension RANDR >/tmp/xvfb.log 2>&1 &
12+
13+
echo "[docker] starting fluxbox window manager"
14+
fluxbox >/tmp/fluxbox.log 2>&1 &
15+
16+
echo "[docker] starting x11vnc on :${VNC_PORT}"
17+
x11vnc \
18+
-display "${DISPLAY}" \
19+
-rfbport "${VNC_PORT}" \
20+
-forever \
21+
-shared \
22+
-nopw \
23+
>/tmp/x11vnc.log 2>&1 &
24+
25+
NOVNC_WEB_ROOT="/usr/share/novnc"
26+
if [[ ! -d "${NOVNC_WEB_ROOT}" ]]; then
27+
NOVNC_WEB_ROOT="/usr/share/novnc/"
28+
fi
29+
echo "[docker] starting noVNC on :${NOVNC_PORT} (web=${NOVNC_WEB_ROOT})"
30+
websockify --web="${NOVNC_WEB_ROOT}" "${NOVNC_PORT}" "127.0.0.1:${VNC_PORT}" >/tmp/novnc.log 2>&1 &
31+
fi
32+
33+
echo "[docker] starting webui..."
34+
exec python webui.py
35+

0 commit comments

Comments
 (0)