diff --git a/scripts/deploy.py b/scripts/deploy.py index f2bdda8..2d444ef 100644 --- a/scripts/deploy.py +++ b/scripts/deploy.py @@ -936,10 +936,15 @@ def deploy_initial() -> int: return 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...") + # 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_COMPOSE_YAML, "leocrm-worker") + worker_compose, "leocrm-worker") if worker_uuid: print(f" Worker service created: {worker_uuid[:12]}") # Set connect_to_docker_network @@ -959,7 +964,17 @@ def deploy_initial() -> int: # Step 5: Deploy API (builds image + runs migrations via prestart.sh) 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)) _print_result(r) if not r.success: @@ -968,11 +983,11 @@ def deploy_initial() -> int: # Step 6: Deploy 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( - 'docker images --format "{{.Repository}}:{{.Tag}}" | ' - 'grep "^stvabl4vaqru7jclx4ittzr3:" | grep -v latest | head -1 | ' - 'xargs -I{} docker tag {} stvabl4vaqru7jclx4ittzr3:latest' + f'docker images --format "{{{{.Repository}}}}:{{{{.Tag}}}}" | ' + f'grep "^{api_uuid}:" | grep -v latest | head -1 | ' + f'xargs -I{{}} docker tag {{}} {api_uuid}:latest' ) # Deploy worker result = client.deploy_application(worker_uuid)