fix: remove AI service host port 8000 binding (conflicts with Coolify)
This commit is contained in:
@@ -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")
|
||||||
+4
-2
@@ -44,8 +44,10 @@ services:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: shoottracker-ai
|
container_name: shoottracker-ai
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
# Pas de ports exposés sur l'hôte : accessible uniquement en interne
|
||||||
- "8000:8000"
|
# (shoottracker-app -> http://shoottracker-ai:8000 via Docker network)
|
||||||
|
expose:
|
||||||
|
- "8000"
|
||||||
environment:
|
environment:
|
||||||
PORT: 8000
|
PORT: 8000
|
||||||
YOLO_MODEL_PATH: yolov8n.pt
|
YOLO_MODEL_PATH: yolov8n.pt
|
||||||
|
|||||||
Reference in New Issue
Block a user