This commit is contained in:
丹尼尔
2026-03-15 17:32:10 +08:00
parent 15c9e1772a
commit 19d8ad3721
7 changed files with 90 additions and 10 deletions

1
.env
View File

@@ -8,6 +8,7 @@ APIKEY=sk-85880595fc714d63bfd0b025e917bd26#千问apikey
# 消息回调ngrok 调通用,由 run-ngrok.sh 自动写入)
CALLBACK_BASE_URL=https://dissonant-destinee-nonsensibly.ngrok-free.dev
# 固定隧道代理socks5h不填登录页代理时后端自动用此处传给 7006
# TUNNEL_PROXY=218.78.109.253:16816
TUNNEL_PROXY=14.103.95.78:16816

22
.env.prod.example Normal file
View File

@@ -0,0 +1,22 @@
# 生产环境变量模板(随项目提交)
# 部署时复制为 .env.prod 并填写真实值cp .env.prod.example .env.prod && 编辑 .env.prod
# run-docker.sh 仅读取 .env.prod不会读取 .env本地开发用
PORT=3003
BACKEND_PORT=8008
WECHAT_UPSTREAM_BASE_URL=http://113.44.162.180:7006
WS_KEY=HBpEnbtj9BJZ
SLIDER_VERIFY_KEY=408449830
APIKEY=sk-85880595fc714d63bfd0b025e917bd26#千问apikey
# 962516e4-60eb-4a26-a5a3-44e21adcf7bc #豆包
# 消息回调ngrok 调通用,由 run-ngrok.sh 自动写入)
CALLBACK_BASE_URL=https://dissonant-destinee-nonsensibly.ngrok-free.dev
# 固定隧道代理socks5h不填登录页代理时后端自动用此处传给 7006
# TUNNEL_PROXY=218.78.109.253:16816
TUNNEL_PROXY=14.103.95.78:16816
TUNNEL_PROXY_USERNAME=fawbjjkk
TUNNEL_PROXY_PASSWORD=5hz6avfb

45
.gitignore vendored Normal file
View File

@@ -0,0 +1,45 @@
# 本地环境(含密钥,不提交)
.env
.env.local
.env.*.local
# 生产环境(服务器上单独维护,不提交)
.env.prod
# 保留模板(随项目提交)
# .env.example
# .env.prod.example
# 依赖与构建
node_modules/
.venv/
venv/
__pycache__/
*.py[cod]
dist/
build/
*.egg-info/
.eggs/
# 数据与日志(可挂载卷)
backend/data/
data/
*.db
*.sqlite
*.log
# 系统与编辑器
.DS_Store
Thumbs.db
.idea/
.vscode/
*.swp
*.swo
*~
# 调试与临时
*.tmp
.cache/
.pytest_cache/
.coverage
htmlcov/

View File

@@ -49,7 +49,9 @@ RUN pip3 install --no-cache-dir --break-system-packages \
python3 -c "import fastapi; import uvicorn; import httpx; import websockets; import openai; print('all deps ok')"
COPY backend ./backend
# 仅复制模板,不复制 .env / .env.prod由 run-docker.sh --env-file .env.prod 注入)
COPY .env.example ./
COPY .env.prod.example ./
COPY start.sh ./
EXPOSE 3000 8000

View File

@@ -15135,3 +15135,8 @@ httpx.ConnectError: All connection attempts failed
2026-03-15 17:15:19,200 [INFO] wechat-backend - HTTP GET /api/push-groups -> 200
2026-03-15 17:15:28,058 [INFO] wechat-backend - HTTP GET /api/ws-status from 127.0.0.1
2026-03-15 17:15:28,059 [INFO] wechat-backend - HTTP GET /api/ws-status -> 200
2026-03-15 17:31:04,260 [INFO] wechat-backend - proxy config: tunnel=True (TUNNEL_PROXY=14.103.95.78:16816), kdl=False (KDL_API=(empty))
2026-03-15 17:31:04,477 [INFO] httpx - HTTP Request: POST http://113.44.162.180:7006/message/SetCallback?key=HBpEnbtj9BJZ "HTTP/1.1 200 OK"
2026-03-15 17:31:04,477 [INFO] wechat-backend - SetCallback registered for key=***9BJZ, CallbackURL=https://dissonant-destinee-nonsensibly.ngrok-free.dev/api/callback/wechat-message
2026-03-15 17:31:04,478 [INFO] wechat-backend - 启动时已注册回调 key=***9BJZ
2026-03-15 17:31:04,478 [INFO] wechat-backend - 消息接收已切换为实时回调入口,不再启动 WS GetSyncMsg

View File

@@ -5616,3 +5616,4 @@
::1 - - [15/Mar/2026:09:15:19 +0000] "GET /api/product-tags?key=HBpEnbtj9BJZ HTTP/1.1" 304 - "http://localhost:3000/manage.html?key=HBpEnbtj9BJZ" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36"
::1 - - [15/Mar/2026:09:15:19 +0000] "GET /api/push-groups?key=HBpEnbtj9BJZ HTTP/1.1" 304 - "http://localhost:3000/manage.html?key=HBpEnbtj9BJZ" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36"
::1 - - [15/Mar/2026:09:15:28 +0000] "GET /api/ws-status HTTP/1.1" 200 19 "http://localhost:3000/manage.html?key=HBpEnbtj9BJZ" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36"
[2026-03-15T09:31:04.748Z] Static frontend server listening on port 3000; access log: /Users/dannier/Desktop/living/AICLW/wechatAiclaw/backend/data/logs/node-access.log

View File

@@ -1,10 +1,11 @@
#!/usr/bin/env bash
# 生产部署脚本:启动前拉取最新代码 → 构建镜像 → 停止旧容器 → 启动新容器
# 环境:仅读取 .env.prod不读 .env。首次部署请 cp .env.prod.example .env.prod 并编辑后执行本脚本。
# 用法: ./run-docker.sh [-p PORT] [-b BACKEND_PORT] [-d HOST_DATA_DIR]
# -p, --port PORT 前端宿主机端口,默认 3000
# -b, --backend-port PORT 后端 API 宿主机端口,默认 8000容器内固定 8000
# -d, --data-dir DIR 数据目录挂载,默认 ./data
cp .env.prod.example .env.prod
set -e
IMAGE_NAME="wechat-admin-backend"
@@ -42,17 +43,20 @@ fi
mkdir -p "${HOST_DATA_DIR}"
echo "Data dir (host): ${HOST_DATA_DIR} -> container /app/backend/data"
# 优先使用 .env.prod 作为生产环境配置(例如在服务器上单独维护 CALLBACK_BASE_URL 等),
# 若不存在则回退到 .env再没有则从 .env.example 复制一份。
if [ -f ".env.prod" ]; then
# 生产仅读取 .env.prod(不读 .env避免混用本地配置
ENV_FILE=".env.prod"
else
ENV_FILE=".env"
if [ ! -f "${ENV_FILE}" ]; then
echo "Env file ${ENV_FILE} not found, copying from .env.example ..."
cp .env.example "${ENV_FILE}"
if [ -f ".env.prod.example" ]; then
echo "Creating ${ENV_FILE} from .env.prod.example ..."
cp .env.prod.example "${ENV_FILE}"
echo "Please edit ${ENV_FILE} with production values (e.g. CALLBACK_BASE_URL, API keys) and run $0 again."
exit 1
else
echo "Error: ${ENV_FILE} and .env.prod.example not found. Cannot start production container."
exit 1
fi
fi
echo "Using env file: ${ENV_FILE}"
echo "Running container ${CONTAINER_NAME} (frontend :${PORT}, backend :${BACKEND_PORT})..."
docker run -d \