fix: 2-phase deploy (first deploy, then set domain without :443 + redeploy)
This commit is contained in:
+43
-18
@@ -1180,24 +1180,8 @@ def deploy_initial() -> int:
|
|||||||
steps.append(("Set envs", StepResult(False, str(e))))
|
steps.append(("Set envs", StepResult(False, str(e))))
|
||||||
_print_result(steps[-1][1])
|
_print_result(steps[-1][1])
|
||||||
|
|
||||||
# Step 4: Set domain via docker_compose_domains + Deploy
|
# Step 4: First Deploy (without domain — Coolify needs to read docker-compose.yaml first)
|
||||||
print("\n[4/4] Setting domain and deploying...")
|
print("\n[4/5] Deploying docker-compose stack (first deploy)...")
|
||||||
if APP_DOMAIN:
|
|
||||||
try:
|
|
||||||
resp = httpx.patch(
|
|
||||||
f"{client.base_url}/api/v1/applications/{app_uuid}",
|
|
||||||
headers=client.headers,
|
|
||||||
json={
|
|
||||||
"docker_compose_domains": [
|
|
||||||
{"name": "crm_app", "domain": f"{APP_DOMAIN}:443"}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
timeout=30,
|
|
||||||
)
|
|
||||||
print(f" Domain set: {APP_DOMAIN}:443 ({resp.status_code})")
|
|
||||||
except Exception as e:
|
|
||||||
print(f" Warning: could not set domain: {e}")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = httpx.post(
|
resp = httpx.post(
|
||||||
f"{client.base_url}/api/v1/deploy",
|
f"{client.base_url}/api/v1/deploy",
|
||||||
@@ -1224,6 +1208,47 @@ def deploy_initial() -> int:
|
|||||||
print_summary(steps)
|
print_summary(steps)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
# Step 5: Set domain via docker_compose_domains (after first deploy, then redeploy)
|
||||||
|
print("\n[5/5] Setting domain and redeploying...")
|
||||||
|
if APP_DOMAIN:
|
||||||
|
try:
|
||||||
|
resp = httpx.patch(
|
||||||
|
f"{client.base_url}/api/v1/applications/{app_uuid}",
|
||||||
|
headers=client.headers,
|
||||||
|
json={
|
||||||
|
"docker_compose_domains": [
|
||||||
|
{"name": "crm_app", "domain": APP_DOMAIN}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
timeout=30,
|
||||||
|
)
|
||||||
|
print(f" Domain set: {APP_DOMAIN} ({resp.status_code})")
|
||||||
|
# Redeploy with domain labels
|
||||||
|
time.sleep(5)
|
||||||
|
resp2 = httpx.post(
|
||||||
|
f"{client.base_url}/api/v1/deploy",
|
||||||
|
headers=client.headers,
|
||||||
|
json={"uuid": app_uuid},
|
||||||
|
timeout=30,
|
||||||
|
)
|
||||||
|
if resp2.status_code == 200:
|
||||||
|
deploy_data = resp2.json()
|
||||||
|
deployments = deploy_data.get("deployments", [])
|
||||||
|
if deployments:
|
||||||
|
deploy_uuid = deployments[0].get("deployment_uuid", "")
|
||||||
|
print(f" Redeploy queued: {deploy_uuid[:12]}")
|
||||||
|
r = _wait_deployment(client, deploy_uuid, timeout=600)
|
||||||
|
else:
|
||||||
|
r = StepResult(True, "Redeploy triggered (no UUID)")
|
||||||
|
else:
|
||||||
|
r = StepResult(False, f"Redeploy failed: {resp2.status_code}")
|
||||||
|
except Exception as e:
|
||||||
|
r = StepResult(False, f"Domain/Redeploy failed: {e}")
|
||||||
|
else:
|
||||||
|
r = StepResult(True, "No domain set (APP_DOMAIN not configured)")
|
||||||
|
steps.append(("Set domain + redeploy", r))
|
||||||
|
_print_result(r)
|
||||||
|
|
||||||
# Verification
|
# Verification
|
||||||
print("\n[5/5] Running verification...")
|
print("\n[5/5] Running verification...")
|
||||||
verify_results = run_verification(client, worker_uuid=None)
|
verify_results = run_verification(client, worker_uuid=None)
|
||||||
|
|||||||
Reference in New Issue
Block a user