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
3 changed files with 57 additions and 0 deletions
Showing only changes of commit 086d1e89e2 - Show all commits

2
.gitignore vendored
View File

@ -19,3 +19,5 @@ git-bridge/state/
litellm/.env litellm/.env
mem0/.env mem0/.env
mem0/history/ mem0/history/
python-worker/runtime.env
python-worker/.migration-state

View File

@ -195,6 +195,38 @@ services:
networks: networks:
- git_forge - git_forge
python_worker:
container_name: python_worker
image: n8n-python_worker
pull_policy: never
restart: unless-stopped
stop_grace_period: 60s
working_dir: /app
env_file:
- ./python-worker/runtime.env
volumes:
- /volume2/docker/n8n/python_worker:/app
- /volume2/docker/n8n/files:/files
ports:
- "8000:8000"
command:
- /bin/sh
- -lc
- . /app/.venv/bin/activate && exec python -m uvicorn fastapi_app:app --host 0.0.0.0 --port 8000 --log-level debug
dns:
- 223.5.5.5
- 114.114.114.114
healthcheck:
test: ["CMD", "/app/.venv/bin/python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=3).read()"]
interval: 10s
timeout: 5s
retries: 18
start_period: 30s
networks:
n8n_backbone:
aliases:
- python_worker
networks: networks:
git_forge: git_forge:
name: git_forge name: git_forge
@ -202,6 +234,10 @@ networks:
external: true external: true
name: n8n_default name: n8n_default
n8n_backbone:
external: true
name: n8n_default
secrets: secrets:
postgres_superuser_password: postgres_superuser_password:
file: ./postgres/secrets/postgres_superuser_password file: ./postgres/secrets/postgres_superuser_password

19
python-worker/README.md Normal file
View File

@ -0,0 +1,19 @@
# 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.