From 846cf1482b892544010a7c1716ef7991da290272 Mon Sep 17 00:00:00 2001 From: ShootTracker Deploy Date: Thu, 30 Apr 2026 23:39:45 +0200 Subject: [PATCH] fix: remove AI service host port 8000 binding (conflicts with Coolify) --- deploy_portfix.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 6 +++-- 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 deploy_portfix.py diff --git a/deploy_portfix.py b/deploy_portfix.py new file mode 100644 index 0000000..b06de77 --- /dev/null +++ b/deploy_portfix.py @@ -0,0 +1,64 @@ +import subprocess +import time +import urllib.request +import json +from pathlib import Path + +REPO_DIR = Path.home() / "Documents/Claude/Projects/Applications VPS/shoottracker" +GITEA_REMOTE = "http://git.domench.fr/gael/shoottracker.git" +COOLIFY_URL = "http://100.94.204.91:8000" +COOLIFY_TOKEN = "2|DGjBZs90ORHr3BsUmJtnxaxC9kc4DdhERhIIaKtWf32da689" +APP_UUID = "lo2xt81gs0zhq3w64ilcy0n6" + +def run(cmd, cwd=None): + r = subprocess.run(cmd, shell=True, cwd=cwd, capture_output=True, text=True, encoding="utf-8", errors="replace") + print(f"$ {cmd}") + if r.stdout.strip(): print(r.stdout.strip()) + if r.stderr.strip(): print(r.stderr.strip()) + return r.returncode + +def api(method, path, data=None): + url = f"{COOLIFY_URL}/api/v1{path}" + body = json.dumps(data).encode() if data else None + req = urllib.request.Request(url, data=body, method=method, + headers={"Authorization": f"Bearer {COOLIFY_TOKEN}", "Content-Type": "application/json"}) + try: + with urllib.request.urlopen(req, timeout=15) as r: + return json.loads(r.read()) + except Exception as e: + print(f"API error: {e}") + return None + +# 1. Git commit & push +print("=== Git commit & push ===") +run("git add -A", cwd=str(REPO_DIR)) +rc = run('git commit -m "fix: remove AI service host port 8000 binding (conflicts with Coolify)"', cwd=str(REPO_DIR)) +if rc != 0: + print("(Nothing to commit or commit failed, trying push anyway)") +rc = run(f"git push {GITEA_REMOTE} main", cwd=str(REPO_DIR)) +if rc != 0: + print("Push failed, aborting.") + exit(1) + +print("\n=== Triggering Coolify deploy ===") +result = api("GET", f"/deploy?uuid={APP_UUID}&force=true") +print(f"Deploy response: {result}") + +# 2. Poll status every 10s, up to 15 min +print("\n=== Polling deployment status ===") +for i in range(90): + time.sleep(10) + app = api("GET", f"/applications/{APP_UUID}") + if not app: + print(f"[{(i+1)*10}s] no response") + continue + status = app.get("status", "?") + print(f"[{(i+1)*10}s] status={status}") + if status == "running": + print("SUCCESS - containers are running!") + break + if status in ("stopped", "exited", "error"): + print(f"FAILED with status: {status}") + break +else: + print("Timed out after 15 min") diff --git a/docker-compose.yml b/docker-compose.yml index f587b06..904fdc0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,8 +44,10 @@ services: dockerfile: Dockerfile container_name: shoottracker-ai restart: unless-stopped - ports: - - "8000:8000" + # Pas de ports exposés sur l'hôte : accessible uniquement en interne + # (shoottracker-app -> http://shoottracker-ai:8000 via Docker network) + expose: + - "8000" environment: PORT: 8000 YOLO_MODEL_PATH: yolov8n.pt