Fix deploy.py: Worker-Deploy repariert

- Tag :latest auf neuestes Commit-Image (Coolify taggt mit Hash, nicht latest)
- Verbinde Worker mit coolify Netzwerk nach Restart (für Redis/Postgres DNS)
- Kein update_service mehr (überschreibt Coolify-Konfiguration)
- Worker-Compose auf Server korrigiert (coolify Netzwerk in Service-Definition)
This commit is contained in:
Agent Zero
2026-08-03 00:12:00 +02:00
parent e2b3cf081b
commit ceb06600c5
+31 -18
View File
@@ -260,35 +260,48 @@ def deploy_api(client: CoolifyClient, skip_build: bool = False) -> StepResult:
def deploy_worker(client: CoolifyClient, skip_build: bool = False) -> StepResult:
"""Deploy or restart the worker service via Coolify API.
"""Restart the worker service via Coolify API.
The worker is a Coolify Service (not an Application), so we cannot use
the /deploy endpoint. Instead we:
1. Update the service's docker_compose_raw (applies new config)
2. Restart the service (pulls latest image and restarts container)
3. Wait for healthy status
The worker is a Coolify Service that uses the same Docker image as the
API application (stvabl4vaqru7jclx4ittzr3:latest). After the API is
rebuilt, the worker just needs a restart to pick up the new image.
We do NOT call update_service because that would overwrite the Coolify
service's compose definition (which has all the correct environment
variables, volumes, and network settings configured via the Coolify UI).
After restart, we ensure:
1. The :latest tag points to the most recent build (Coolify tags with
commit hashes, not :latest)
2. The worker container is connected to the coolify network (needed to
reach crm-redis and crm-postgres)
"""
print(" Deploying worker service via Coolify API...")
try:
if skip_build:
# Just restart the existing service
print(" Skip-build mode: restarting worker service...")
client.restart_service(WORKER_UUID)
time.sleep(3)
return _wait_service_healthy(client, WORKER_UUID, timeout=120)
# Step 1: Update the service with the latest docker_compose_raw
print(" Updating worker service compose definition...")
client.update_service(WORKER_UUID, WORKER_COMPOSE_YAML)
time.sleep(2)
# Step 1: Tag the latest API image as :latest (Coolify uses commit-hash tags)
print(" Tagging latest API image as :latest...")
tag_code, tag_output = ssh_run(
'docker images --format "{{.Repository}}:{{.Tag}}" | '
'grep "^stvabl4vaqru7jclx4ittzr3:" | grep -v latest | tail -1 | '
'xargs -I{} docker tag {} stvabl4vaqru7jclx4ittzr3:latest'
)
if tag_code != 0:
print(f" Warning: could not tag :latest ({tag_output.strip()})")
# Step 2: Restart the service to pick up the latest image
print(" Restarting worker service...")
client.restart_service(WORKER_UUID)
time.sleep(5)
# Step 3: Wait for service to be healthy
# Step 3: Ensure worker is connected to coolify network
print(" Ensuring coolify network connection...")
net_code, net_output = ssh_run(
'docker network connect coolify worker-asxqaq3566to108xordck0ff 2>/dev/null; '
'echo done'
)
# Step 4: Wait for service to be healthy
return _wait_service_healthy(client, WORKER_UUID, timeout=120)
except Exception as e: