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: 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 worker is a Coolify Service that uses the same Docker image as the
the /deploy endpoint. Instead we: API application (stvabl4vaqru7jclx4ittzr3:latest). After the API is
1. Update the service's docker_compose_raw (applies new config) rebuilt, the worker just needs a restart to pick up the new image.
2. Restart the service (pulls latest image and restarts container)
3. Wait for healthy status 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...") print(" Deploying worker service via Coolify API...")
try: try:
if skip_build: # Step 1: Tag the latest API image as :latest (Coolify uses commit-hash tags)
# Just restart the existing service print(" Tagging latest API image as :latest...")
print(" Skip-build mode: restarting worker service...") tag_code, tag_output = ssh_run(
client.restart_service(WORKER_UUID) 'docker images --format "{{.Repository}}:{{.Tag}}" | '
time.sleep(3) 'grep "^stvabl4vaqru7jclx4ittzr3:" | grep -v latest | tail -1 | '
return _wait_service_healthy(client, WORKER_UUID, timeout=120) 'xargs -I{} docker tag {} stvabl4vaqru7jclx4ittzr3:latest'
)
# Step 1: Update the service with the latest docker_compose_raw if tag_code != 0:
print(" Updating worker service compose definition...") print(f" Warning: could not tag :latest ({tag_output.strip()})")
client.update_service(WORKER_UUID, WORKER_COMPOSE_YAML)
time.sleep(2)
# Step 2: Restart the service to pick up the latest image # Step 2: Restart the service to pick up the latest image
print(" Restarting worker service...") print(" Restarting worker service...")
client.restart_service(WORKER_UUID) client.restart_service(WORKER_UUID)
time.sleep(5) 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) return _wait_service_healthy(client, WORKER_UUID, timeout=120)
except Exception as e: except Exception as e: