deploy.py: --initial mit API-UUID fuer Worker-Image und Deploy

This commit is contained in:
Agent Zero
2026-08-03 02:16:31 +02:00
parent 0c789f7660
commit 95972d2cdd
+22 -7
View File
@@ -936,10 +936,15 @@ def deploy_initial() -> int:
return 1 return 1
_print_result(steps[-1][1]) _print_result(steps[-1][1])
# Step 4: Create Worker service # Step 4: Create Worker service (with API image reference)
print("\n[4/7] Creating Worker service...") print("\n[4/7] Creating Worker service...")
# Generate worker compose with the API application's UUID as image name
worker_compose = WORKER_COMPOSE_YAML.replace(
"stvabl4vaqru7jclx4ittzr3:latest",
f"{api_uuid}:latest",
)
worker_uuid = create_service(client, PROJECT_UUID, ENVIRONMENT_NAME, SERVER_UUID, worker_uuid = create_service(client, PROJECT_UUID, ENVIRONMENT_NAME, SERVER_UUID,
WORKER_COMPOSE_YAML, "leocrm-worker") worker_compose, "leocrm-worker")
if worker_uuid: if worker_uuid:
print(f" Worker service created: {worker_uuid[:12]}") print(f" Worker service created: {worker_uuid[:12]}")
# Set connect_to_docker_network # Set connect_to_docker_network
@@ -959,7 +964,17 @@ def deploy_initial() -> int:
# Step 5: Deploy API (builds image + runs migrations via prestart.sh) # Step 5: Deploy API (builds image + runs migrations via prestart.sh)
print("\n[5/7] Deploying API (build + migrations)...") print("\n[5/7] Deploying API (build + migrations)...")
r = deploy_api(client, skip_build=False) # Use the newly created API application UUID for deployment
try:
result = client.deploy_application(api_uuid)
deploy_uuid = _extract_deploy_uuid(result)
if deploy_uuid:
print(f" Deploy queued: {deploy_uuid[:12]}")
r = _wait_deployment(client, deploy_uuid, timeout=300)
else:
r = StepResult(True, "Deploy triggered (no UUID)")
except Exception as e:
r = StepResult(False, f"Deploy failed: {e}")
steps.append(("API deploy", r)) steps.append(("API deploy", r))
_print_result(r) _print_result(r)
if not r.success: if not r.success:
@@ -968,11 +983,11 @@ def deploy_initial() -> int:
# Step 6: Deploy Worker # Step 6: Deploy Worker
print("\n[6/7] Deploying Worker...") print("\n[6/7] Deploying Worker...")
# Tag the latest API image as :latest # Tag the latest API image as :latest (using the new API UUID)
tag_code, tag_output = ssh_run( tag_code, tag_output = ssh_run(
'docker images --format "{{.Repository}}:{{.Tag}}" | ' f'docker images --format "{{{{.Repository}}}}:{{{{.Tag}}}}" | '
'grep "^stvabl4vaqru7jclx4ittzr3:" | grep -v latest | head -1 | ' f'grep "^{api_uuid}:" | grep -v latest | head -1 | '
'xargs -I{} docker tag {} stvabl4vaqru7jclx4ittzr3:latest' f'xargs -I{{}} docker tag {{}} {api_uuid}:latest'
) )
# Deploy worker # Deploy worker
result = client.deploy_application(worker_uuid) result = client.deploy_application(worker_uuid)