Move Python Worker ownership into Infra #6

Merged
slh merged 2 commits from chore/migrate-python-worker-to-infra into main 2026-07-17 15:02:08 +08:00
4 changed files with 34 additions and 23 deletions
Showing only changes of commit 1dd4b0adda - Show all commits

6
.gitignore vendored
View File

@ -19,5 +19,7 @@ git-bridge/state/
litellm/.env
mem0/.env
mem0/history/
python-worker/runtime.env
python-worker/.migration-state
python_worker/app/
python_worker/runtime.env
python_worker/.migration-state
python_worker/.staged-from-n8n

View File

@ -203,9 +203,9 @@ services:
stop_grace_period: 60s
working_dir: /app
env_file:
- ./python-worker/runtime.env
- ./python_worker/runtime.env
volumes:
- /volume2/docker/n8n/python_worker:/app
- ./python_worker/app:/app
- /volume2/docker/n8n/files:/files
ports:
- "8000:8000"

View File

@ -1,19 +0,0 @@
# Python Worker
This is the first, compatibility-preserving ownership migration of the shared
FastAPI worker from the n8n Compose project into Infra.
The service deliberately keeps the existing container name, port, local image,
source/state mounts, files mount, and `n8n_default` network. Therefore n8n and
the OGame Agent continue to use `http://python_worker:8000` without workflow
changes. The absent `playwright_chrome` runtime is not migrated; current OGame
automation uses the existing CDP browser endpoint.
Host-specific, non-secret runtime values are captured during cutover in the
ignored `python-worker/runtime.env` file with mode `0600`. The 921 MB source and
state directory remains at `/volume2/docker/n8n/python_worker` for this phase so
rollback does not require a data copy.
The local `n8n-python_worker` image is transitional. A later reviewed change
must add a pinned production Dockerfile and remove boot-time package installs
before the old image can be considered reproducible.

28
python_worker/README.md Normal file
View File

@ -0,0 +1,28 @@
# Python Worker
`python_worker` 是 n8n、OGame Agent 与其他自动化流程共同使用的 FastAPI
服务。本次迁移只调整运行归属和宿主机目录,不重构业务接口。
## 目录边界
- `app/`:从 `/volume2/docker/n8n/python_worker` 分两阶段同步的应用、虚拟
环境和运行状态,不纳入 Git。
- `runtime.env`:从旧容器提取的宿主机运行参数,权限必须为 `0600`,不包含
模型或平台凭据,不纳入 Git。
- `.migration-state`:切换成功后写入的回滚定位信息,不纳入 Git。
- `README.md`:唯一纳入 Gitea 的目录说明。
容器继续使用 `python_worker` 名称、8000 端口和 `n8n_default` 网络,因此现有
n8n 工作流及 OGame Agent 仍通过 `http://python_worker:8000` 访问,不需要修改
调用地址。`/files` 仍是 n8n 与 Worker 共用的数据目录,本阶段不迁移。
## 迁移策略
迁移前先在旧 Worker 在线时把约 921 MB 的目录预复制到
`/volume2/docker/infra/python_worker/app`。正式切换时停止旧容器,再执行一次
增量同步,随后由 Infra Compose 启动新容器。旧目录和停止状态的旧容器都会
保留,以便回滚。
当前沿用本地镜像 `n8n-python_worker` 和已有 `.venv`,这是降低首次迁移风险的
过渡方案。后续必须单独补充固定版本的生产 Dockerfile停止容器启动时联网安装
依赖,再将该服务纳入可复现构建。