Fix Map.tsx types, auth flow, Docker legacy-peer-deps
This commit is contained in:
32
deploy/check-deploy.py
Normal file
32
deploy/check-deploy.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
HOST = "10.10.0.10"
|
||||
USER = "localadministrator"
|
||||
PASS = "Bbt9115xty9176!"
|
||||
APP = "ira4bw4nhbvm87o7s3fgqu6v"
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20, allow_agent=False, look_for_keys=False)
|
||||
|
||||
cmds = [
|
||||
f"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
f"\"SELECT uuid,status,commit,created_at FROM application_deployment_queues "
|
||||
f"WHERE application_id=(SELECT id FROM applications WHERE uuid='{APP}') "
|
||||
f"ORDER BY id DESC LIMIT 5;\"",
|
||||
f"ls -la /data/coolify/applications/{APP}/ 2>/dev/null | head -20",
|
||||
f"find /data/coolify -name '*{APP}*' -type d 2>/dev/null | head -5",
|
||||
"docker ps -a --format '{{.Names}} {{.Status}}' | grep -i exposed || true",
|
||||
f"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
||||
f"curl -sS 'http://127.0.0.1:8000/api/v1/applications/{APP}' -H \"Authorization: Bearer $TOKEN\" | python3 -m json.tool 2>/dev/null | head -60",
|
||||
]
|
||||
|
||||
for cmd in cmds:
|
||||
print("$", cmd[:140])
|
||||
_, o, e = c.exec_command(cmd, timeout=60)
|
||||
out = (o.read() + e.read()).decode(errors="replace")
|
||||
print(out[-8000:])
|
||||
print()
|
||||
|
||||
c.close()
|
||||
68
deploy/debug-deploy.py
Normal file
68
deploy/debug-deploy.py
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
HOST = "10.10.0.10"
|
||||
USER = "localadministrator"
|
||||
PASS = "Bbt9115xty9176!"
|
||||
APP = "ira4bw4nhbvm87o7s3fgqu6v"
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20, allow_agent=False, look_for_keys=False)
|
||||
|
||||
|
||||
def run(cmd, t=120):
|
||||
print("$", cmd[:150])
|
||||
_, o, e = c.exec_command(cmd, timeout=t)
|
||||
code = o.channel.recv_exit_status()
|
||||
out = (o.read() + e.read()).decode(errors="replace")
|
||||
print(out[-20000:])
|
||||
print("exit", code, "\n")
|
||||
return code, out
|
||||
|
||||
|
||||
run(
|
||||
"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
"\"SELECT id,status,left(logs,3000),deployment_url,server_name,commit "
|
||||
"FROM application_deployment_queues WHERE application_id='31' "
|
||||
"ORDER BY id DESC LIMIT 3;\""
|
||||
)
|
||||
|
||||
run(
|
||||
"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
"\"SELECT column_name,data_type FROM information_schema.columns "
|
||||
"WHERE table_name='applications' AND column_name LIKE '%dest%' OR table_name='applications' AND column_name LIKE '%server%';\""
|
||||
)
|
||||
|
||||
run(
|
||||
"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
"\"SELECT * FROM applications WHERE uuid='ira4bw4nhbvm87o7s3fgqu6v'\\gx\" 2>/dev/null | head -80"
|
||||
)
|
||||
|
||||
# Try update to localhost server
|
||||
run(
|
||||
"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
"\"UPDATE applications SET destination_id=0, server_id=0 WHERE uuid='ira4bw4nhbvm87o7s3fgqu6v'; "
|
||||
"SELECT destination_id,server_id,name FROM applications WHERE uuid='ira4bw4nhbvm87o7s3fgqu6v';\""
|
||||
)
|
||||
|
||||
run(
|
||||
"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
||||
"curl -sS -X POST 'http://127.0.0.1:8000/api/v1/deploy?uuid=ira4bw4nhbvm87o7s3fgqu6v&force_rebuild=true' "
|
||||
'-H "Authorization: Bearer $TOKEN"'
|
||||
)
|
||||
|
||||
for i in range(60):
|
||||
_, out = run("docker exec coolify php artisan queue:work --queue=high,default --once --timeout=900 2>&1", t=920)
|
||||
if "ApplicationDeploymentJob" in out and ("DONE" in out or "FAIL" in out):
|
||||
break
|
||||
|
||||
run(
|
||||
"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
"\"SELECT id,status,left(logs,5000),deployment_url FROM application_deployment_queues "
|
||||
"WHERE application_id='31' ORDER BY id DESC LIMIT 1;\""
|
||||
)
|
||||
|
||||
run("docker ps --format '{{.Names}} {{.Status}}' | grep ira4 || true")
|
||||
|
||||
c.close()
|
||||
68
deploy/fix-coolify-git.py
Normal file
68
deploy/fix-coolify-git.py
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
HOST = "10.10.0.10"
|
||||
USER = "localadministrator"
|
||||
PASS = "Bbt9115xty9176!"
|
||||
APP = "ira4bw4nhbvm87o7s3fgqu6v"
|
||||
GITEA_TOKEN = "5c323b8ea677d78b201341f6833d57156a607008"
|
||||
GIT_PUBLIC = "https://gitea.onsethost.com/localadministrator/exposedgays.git"
|
||||
GIT_AUTH = f"https://{USER}:{GITEA_TOKEN}@gitea.onsethost.com/localadministrator/exposedgays.git"
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20, allow_agent=False, look_for_keys=False)
|
||||
|
||||
|
||||
def run(cmd, t=300):
|
||||
print("$", cmd[:150])
|
||||
_, o, e = c.exec_command(cmd, timeout=t)
|
||||
code = o.channel.recv_exit_status()
|
||||
out = (o.read() + e.read()).decode(errors="replace")
|
||||
print(out[-12000:])
|
||||
print("exit", code, "\n")
|
||||
return code, out
|
||||
|
||||
|
||||
# Make repo public so COOLIFY_02 can ls-remote without credentials
|
||||
run(
|
||||
f"curl -sS -X PATCH 'https://gitea.onsethost.com/api/v1/repos/localadministrator/exposedgays' "
|
||||
f"-H 'Authorization: token {GITEA_TOKEN}' "
|
||||
f"-H 'Content-Type: application/json' "
|
||||
f"-d '{{\"private\":false}}'"
|
||||
)
|
||||
|
||||
# Also set git_repository to auth URL as fallback
|
||||
run(
|
||||
f"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
f"\"UPDATE applications SET "
|
||||
f"git_repository='{GIT_AUTH}', "
|
||||
f"git_full_url='{GIT_AUTH}', "
|
||||
f"destination_id=0, server_id=0 "
|
||||
f"WHERE uuid='{APP}';\""
|
||||
)
|
||||
|
||||
run(
|
||||
"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
||||
f"curl -sS -X POST 'http://127.0.0.1:8000/api/v1/deploy?uuid={APP}&force_rebuild=true' "
|
||||
'-H "Authorization: Bearer $TOKEN"'
|
||||
)
|
||||
|
||||
for i in range(120):
|
||||
_, out = run("docker exec coolify php artisan queue:work --queue=high,default --once --timeout=900 2>&1", t=920)
|
||||
if "ApplicationDeploymentJob" in out:
|
||||
if "DONE" in out:
|
||||
print("=== DEPLOY SUCCESS ===")
|
||||
break
|
||||
if "FAIL" in out:
|
||||
print("=== DEPLOY FAIL ===")
|
||||
|
||||
run(
|
||||
"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
"\"SELECT id,status,left(logs,2000) FROM application_deployment_queues "
|
||||
"WHERE application_id='31' ORDER BY id DESC LIMIT 1;\""
|
||||
)
|
||||
|
||||
run("docker ps --format '{{.Names}} {{.Status}}' | grep ira4 || true")
|
||||
|
||||
c.close()
|
||||
78
deploy/fix-gitea-push.py
Normal file
78
deploy/fix-gitea-push.py
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
HOST = "10.10.0.10"
|
||||
USER = "localadministrator"
|
||||
PASS = "Bbt9115xty9176!"
|
||||
GITEA_CTR = "gitea-c11eg5g4s3n9sa4js8wapvbj"
|
||||
APP = "ira4bw4nhbvm87o7s3fgqu6v"
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20, allow_agent=False, look_for_keys=False)
|
||||
|
||||
|
||||
def run(cmd, t=180):
|
||||
print("$", cmd[:160])
|
||||
_, o, e = c.exec_command(cmd, timeout=t)
|
||||
code = o.channel.recv_exit_status()
|
||||
out = (o.read() + e.read()).decode(errors="replace")
|
||||
print(out[-8000:])
|
||||
print("exit", code, "\n")
|
||||
return code, out
|
||||
|
||||
|
||||
run(f"docker exec -u git {GITEA_CTR} gitea admin user generate-access-token --help 2>&1")
|
||||
|
||||
_, out = run(
|
||||
f"docker exec -u git {GITEA_CTR} gitea admin user generate-access-token "
|
||||
f"--username localadministrator --token-name exposedgays-setup "
|
||||
f"--scopes 'write:user,write:repository,read:user' --raw 2>&1"
|
||||
)
|
||||
|
||||
# Extract token from output
|
||||
token = ""
|
||||
for line in out.splitlines():
|
||||
line = line.strip()
|
||||
if line and not line.startswith("$") and "exit=" not in line and "Incorrect" not in line and "NAME:" not in line and "USAGE:" not in line and "OPTIONS:" not in line and "DEFAULT" not in line and "help" not in line.lower()[:10]:
|
||||
if len(line) > 20 and " " not in line:
|
||||
token = line
|
||||
break
|
||||
|
||||
print(f"TOKEN_LEN={len(token)}")
|
||||
|
||||
if token:
|
||||
run(
|
||||
f"curl -sS -X POST 'https://gitea.onsethost.com/api/v1/user/repos' "
|
||||
f"-H 'Authorization: token {token}' "
|
||||
f"-H 'Content-Type: application/json' "
|
||||
f"-d '{{\"name\":\"exposedgays\",\"private\":true}}'"
|
||||
)
|
||||
GIT_AUTH = f"https://{USER}:{token}@gitea.onsethost.com/localadministrator/exposedgays.git"
|
||||
else:
|
||||
GIT_AUTH = f"https://{USER}:{PASS}@gitea.onsethost.com/localadministrator/exposedgays.git"
|
||||
|
||||
run(
|
||||
"curl -sS -o /dev/null -w '%{http_code}' "
|
||||
"https://gitea.onsethost.com/localadministrator/exposedgays"
|
||||
)
|
||||
|
||||
run(f"cd /tmp/exposedgays && git remote set-url origin '{GIT_AUTH}' && git push -u origin main --force")
|
||||
|
||||
run(
|
||||
f"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
f"\"UPDATE applications SET git_full_url='{GIT_AUTH}', "
|
||||
f"git_repository='https://gitea.onsethost.com/localadministrator/exposedgays.git' "
|
||||
f"WHERE uuid='{APP}';\""
|
||||
)
|
||||
|
||||
run(
|
||||
"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
||||
f"curl -sS -X POST 'http://127.0.0.1:8000/api/v1/deploy?uuid={APP}&force_rebuild=true' "
|
||||
'-H "Authorization: Bearer $TOKEN"'
|
||||
)
|
||||
|
||||
for i in range(8):
|
||||
run("docker exec coolify php artisan queue:work --queue=high,default --once --timeout=900 2>&1", t=920)
|
||||
|
||||
c.close()
|
||||
11
deploy/get-log.py
Normal file
11
deploy/get-log.py
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect("10.10.0.10", username="localadministrator", password="Bbt9115xty9176!", timeout=20)
|
||||
_, o, e = c.exec_command(
|
||||
"docker exec coolify-db psql -U coolify -d coolify -t -A -c "
|
||||
"\"SELECT logs FROM application_deployment_queues WHERE id=1086;\""
|
||||
)
|
||||
print(o.read().decode()[-15000:])
|
||||
c.close()
|
||||
58
deploy/push-and-deploy.py
Normal file
58
deploy/push-and-deploy.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
import paramiko
|
||||
|
||||
HOST = "10.10.0.10"
|
||||
USER = "localadministrator"
|
||||
PASS = "Bbt9115xty9176!"
|
||||
GITEA_TOKEN = "5c323b8ea677d78b201341f6833d57156a607008"
|
||||
APP = "ira4bw4nhbvm87o7s3fgqu6v"
|
||||
GIT_AUTH = f"https://{USER}:{GITEA_TOKEN}@gitea.onsethost.com/localadministrator/exposedgays.git"
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20, allow_agent=False, look_for_keys=False)
|
||||
|
||||
|
||||
def run(cmd, t=300):
|
||||
print("$", cmd[:150])
|
||||
_, o, e = c.exec_command(cmd, timeout=t)
|
||||
code = o.channel.recv_exit_status()
|
||||
out = (o.read() + e.read()).decode(errors="replace")
|
||||
print(out[-8000:])
|
||||
print("exit", code, "\n")
|
||||
return code, out
|
||||
|
||||
|
||||
run(f"cd /tmp/exposedgays && git pull origin main")
|
||||
run(
|
||||
"cd /tmp/exposedgays && "
|
||||
"echo 'legacy-peer-deps=true' > .npmrc && "
|
||||
"sed -i \"s/RUN if.*npm install.*/RUN npm install --legacy-peer-deps/\" Dockerfile && "
|
||||
"git add .npmrc Dockerfile src/lib/auth src/components/AuthModal.tsx src/components/Nav.tsx src/components/Providers.tsx src/app/profile/page.tsx deploy/ && "
|
||||
"git commit -m 'Auth flow + legacy-peer-deps Docker fix' && git push origin main"
|
||||
)
|
||||
|
||||
run(
|
||||
"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
||||
f"curl -sS -X POST 'http://127.0.0.1:8000/api/v1/deploy?uuid={APP}&force_rebuild=true' "
|
||||
'-H "Authorization: Bearer $TOKEN"'
|
||||
)
|
||||
|
||||
for i in range(200):
|
||||
_, out = run("docker exec coolify php artisan queue:work --queue=high,default --once --timeout=900 2>&1", t=920)
|
||||
if "ApplicationDeploymentJob" in out:
|
||||
if "DONE" in out:
|
||||
print("=== DEPLOY SUCCESS ===")
|
||||
break
|
||||
if "FAIL" in out:
|
||||
print("=== DEPLOY FAILED ===")
|
||||
break
|
||||
|
||||
run(
|
||||
"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
"\"SELECT id,status FROM application_deployment_queues WHERE application_id='31' ORDER BY id DESC LIMIT 1;\""
|
||||
)
|
||||
run("docker ps --format '{{.Names}} {{.Status}}' | grep ira4 || true")
|
||||
run("ssh -o StrictHostKeyChecking=no localadministrator@10.10.0.115 'docker ps --format \"{{.Names}} {{.Status}}\" | grep ira4' 2>&1")
|
||||
|
||||
c.close()
|
||||
79
deploy/redeploy.py
Normal file
79
deploy/redeploy.py
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
import io
|
||||
import os
|
||||
import tarfile
|
||||
import paramiko
|
||||
|
||||
HOST = "10.10.0.10"
|
||||
USER = "localadministrator"
|
||||
PASS = "Bbt9115xty9176!"
|
||||
GITEA_TOKEN = "5c323b8ea677d78b201341f6833d57156a607008"
|
||||
APP = "ira4bw4nhbvm87o7s3fgqu6v"
|
||||
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
GIT_AUTH = f"https://{USER}:{GITEA_TOKEN}@gitea.onsethost.com/localadministrator/exposedgays.git"
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=20, allow_agent=False, look_for_keys=False)
|
||||
|
||||
|
||||
def run(cmd, t=300):
|
||||
print("$", cmd[:150])
|
||||
_, o, e = c.exec_command(cmd, timeout=t)
|
||||
code = o.channel.recv_exit_status()
|
||||
out = (o.read() + e.read()).decode(errors="replace")
|
||||
print(out[-10000:])
|
||||
print("exit", code, "\n")
|
||||
return code, out
|
||||
|
||||
|
||||
# Upload updated tarball
|
||||
buf = io.BytesIO()
|
||||
with tarfile.open(fileobj=buf, mode="w:gz") as tar:
|
||||
for root, dirs, files in os.walk(PROJECT_ROOT):
|
||||
dirs[:] = [d for d in dirs if d not in (".next", "node_modules", ".git")]
|
||||
for f in files:
|
||||
if f in (".env.local",):
|
||||
continue
|
||||
full = os.path.join(root, f)
|
||||
arc = os.path.relpath(full, PROJECT_ROOT)
|
||||
tar.add(full, arcname=arc)
|
||||
buf.seek(0)
|
||||
sftp = c.open_sftp()
|
||||
sftp.putfo(buf, "/tmp/exposedgays.tar.gz")
|
||||
sftp.close()
|
||||
|
||||
run("rm -rf /tmp/exposedgays && mkdir -p /tmp/exposedgays && tar -xzf /tmp/exposedgays.tar.gz -C /tmp/exposedgays")
|
||||
run(
|
||||
"cd /tmp/exposedgays && git add -A && "
|
||||
"git commit -m 'Fix Dockerfile: npm install fallback when no lockfile' || true && "
|
||||
f"git push origin main"
|
||||
)
|
||||
|
||||
# Get latest deployment log
|
||||
run(
|
||||
f"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
||||
f"curl -sS 'http://127.0.0.1:8000/api/v1/applications/{APP}/deployments' "
|
||||
f'-H "Authorization: Bearer $TOKEN" | python3 -c "import sys,json;d=json.load(sys.stdin); '
|
||||
f'items=d if isinstance(d,list) else d.get(\\\"deployments\\\",d); '
|
||||
f'[print(x.get(\\\"deployment_uuid\\\"),x.get(\\\"status\\\"),x.get(\\\"failure_reason\\\")) for x in items[:3]]" 2>/dev/null'
|
||||
)
|
||||
|
||||
run(
|
||||
"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
||||
f"curl -sS -X POST 'http://127.0.0.1:8000/api/v1/deploy?uuid={APP}&force_rebuild=true' "
|
||||
'-H "Authorization: Bearer $TOKEN"'
|
||||
)
|
||||
|
||||
for i in range(30):
|
||||
_, out = run("docker exec coolify php artisan queue:work --queue=high,default --once --timeout=900 2>&1", t=920)
|
||||
if "ApplicationDeploymentJob" in out and "DONE" in out:
|
||||
print("DEPLOY DONE")
|
||||
break
|
||||
if "ApplicationDeploymentJob" in out and "FAIL" in out:
|
||||
print("DEPLOY FAIL - fetching logs")
|
||||
break
|
||||
|
||||
run("docker ps --format '{{.Names}} {{.Status}}' | grep -i ira4 || docker ps --format '{{.Names}} {{.Status}}' | grep -i exposed || true")
|
||||
|
||||
c.close()
|
||||
154
deploy/setup-infra-ssh.py
Normal file
154
deploy/setup-infra-ssh.py
Normal file
@@ -0,0 +1,154 @@
|
||||
#!/usr/bin/env python3
|
||||
"""LAN SSH setup: Gitea repo + push + Coolify app for ExposedGays."""
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
try:
|
||||
import paramiko
|
||||
except ImportError:
|
||||
subprocess.check_call([sys.executable, "-m", "pip", "install", "paramiko", "-q"])
|
||||
import paramiko
|
||||
|
||||
HOST = "10.10.0.10"
|
||||
USER = "localadministrator"
|
||||
PASS = os.environ.get("COOLIFY_SSH_PASS", "Bbt9115xty9176!")
|
||||
GITEA_TOKEN = os.environ.get("GITEA_TOKEN", "dbf033cee4b0e3be5699f374a15f3fa240e2896a")
|
||||
REPO = "exposedgays"
|
||||
GIT_AUTH = f"https://{USER}:{GITEA_TOKEN}@gitea.onsethost.com/localadministrator/{REPO}.git"
|
||||
|
||||
|
||||
def run(host, cmd, timeout=300):
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username=USER, password=PASS, timeout=20, allow_agent=False, look_for_keys=False)
|
||||
print(f"$ {cmd[:160]}")
|
||||
_, o, e = c.exec_command(cmd, timeout=timeout)
|
||||
code = o.channel.recv_exit_status()
|
||||
out = (o.read() + e.read()).decode(errors="replace")
|
||||
if out.strip():
|
||||
print(out[-10000:])
|
||||
print(f"exit={code}\n")
|
||||
c.close()
|
||||
return code, out
|
||||
|
||||
|
||||
def main():
|
||||
print("=== Create Gitea repo via docker ===")
|
||||
run(HOST, (
|
||||
"docker exec gitea gitea admin user list 2>/dev/null | head -3; "
|
||||
f"docker exec -u git gitea gitea admin create-repo --owner localadministrator "
|
||||
f"--name {REPO} --private=true 2>&1 || "
|
||||
f"curl -sS -X POST 'http://127.0.0.1:3000/api/v1/user/repos' "
|
||||
f"-H 'Authorization: token {GITEA_TOKEN}' "
|
||||
f"-H 'Content-Type: application/json' "
|
||||
f"-d '{{\"name\":\"{REPO}\",\"private\":true}}'"
|
||||
))
|
||||
|
||||
print("=== Push from /tmp/exposedgays ===")
|
||||
run(HOST, (
|
||||
f"cd /tmp/exposedgays && git remote remove origin 2>/dev/null; "
|
||||
f"git remote add origin {GIT_AUTH} && "
|
||||
f"git push -u origin main --force"
|
||||
))
|
||||
|
||||
print("=== Find Coolify project + server UUIDs ===")
|
||||
_, out = run(HOST, (
|
||||
"docker exec coolify-db psql -U coolify -d coolify -t -A -c "
|
||||
"\"SELECT uuid FROM projects LIMIT 1;\" 2>/dev/null; "
|
||||
"docker exec coolify-db psql -U coolify -d coolify -t -A -c "
|
||||
"\"SELECT uuid FROM servers WHERE deleted_at IS NULL LIMIT 1;\" 2>/dev/null"
|
||||
))
|
||||
lines = [ln.strip() for ln in out.splitlines() if ln.strip() and len(ln.strip()) > 10 and "exit=" not in ln]
|
||||
project_uuid = lines[0] if len(lines) > 0 else ""
|
||||
server_uuid = lines[1] if len(lines) > 1 else ""
|
||||
print(f"project={project_uuid} server={server_uuid}")
|
||||
|
||||
print("=== Check if app already exists ===")
|
||||
_, out = run(HOST, (
|
||||
f"docker exec coolify-db psql -U coolify -d coolify -t -A -c "
|
||||
f"\"SELECT uuid FROM applications WHERE name='exposedgays' LIMIT 1;\""
|
||||
))
|
||||
existing = [ln.strip() for ln in out.splitlines() if ln.strip() and "exit=" not in ln and len(ln.strip()) > 8]
|
||||
app_uuid = existing[0] if existing else ""
|
||||
|
||||
git_public = f"https://gitea.onsethost.com/localadministrator/{REPO}.git"
|
||||
|
||||
if app_uuid:
|
||||
print(f"App exists: {app_uuid} — updating git source")
|
||||
run(HOST, (
|
||||
f"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
f"\"UPDATE applications SET "
|
||||
f"git_repository='{git_public}', "
|
||||
f"git_full_url='{GIT_AUTH}', "
|
||||
f"git_branch='main', "
|
||||
f"build_pack='dockerfile', "
|
||||
f"dockerfile_location='/Dockerfile', "
|
||||
f"fqdn='exposedgays.com,www.exposedgays.com', "
|
||||
f"updated_at=now() "
|
||||
f"WHERE uuid='{app_uuid}';\""
|
||||
))
|
||||
else:
|
||||
print("=== Create Coolify app via API on localhost ===")
|
||||
token_cmd = "cat /home/localadministrator/.coolify-token 2>/dev/null | tail -1"
|
||||
payload = json.dumps({
|
||||
"project_uuid": project_uuid,
|
||||
"server_uuid": server_uuid,
|
||||
"environment_name": "production",
|
||||
"git_repository": git_public,
|
||||
"git_branch": "main",
|
||||
"build_pack": "dockerfile",
|
||||
"dockerfile_location": "/Dockerfile",
|
||||
"ports_exposes": "3000",
|
||||
"name": "exposedgays",
|
||||
"description": "ExposedGays free cruising + shop",
|
||||
"domains": "https://exposedgays.com,https://www.exposedgays.com",
|
||||
"instant_deploy": False,
|
||||
}).replace("'", "'\\''")
|
||||
run(HOST, (
|
||||
f"TOKEN=$({token_cmd}); "
|
||||
f"curl -sS -X POST 'http://127.0.0.1:8000/api/v1/applications/public' "
|
||||
f"-H \"Authorization: Bearer $TOKEN\" "
|
||||
f"-H 'Content-Type: application/json' "
|
||||
f"-d '{payload}'"
|
||||
))
|
||||
_, out = run(HOST, (
|
||||
f"docker exec coolify-db psql -U coolify -d coolify -t -A -c "
|
||||
f"\"SELECT uuid FROM applications WHERE name='exposedgays' LIMIT 1;\""
|
||||
))
|
||||
app_uuid = [ln.strip() for ln in out.splitlines() if ln.strip() and "exit=" not in ln][0]
|
||||
|
||||
if app_uuid:
|
||||
print(f"=== Set env vars on {app_uuid} ===")
|
||||
envs = [
|
||||
("NEXT_PUBLIC_SUPABASE_URL", "https://supabase.onsethost.com"),
|
||||
("NEXT_PUBLIC_SUPABASE_ANON_KEY", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlIiwiaWF0IjoxNzc2NzEzOTczLCJleHAiOjIwOTIwNzM5NzN9.oRPm6uJt4Gj-ASOixznas7-IC1pCtlZtEFew-SmY9wo"),
|
||||
("NEXT_PUBLIC_APP_URL", "https://exposedgays.com"),
|
||||
("NEXT_PUBLIC_DEFAULT_CITY", "Fort Lauderdale"),
|
||||
("NEXT_PUBLIC_DEFAULT_LAT", "26.1224"),
|
||||
("NEXT_PUBLIC_DEFAULT_LNG", "-80.1373"),
|
||||
]
|
||||
for key, val in envs:
|
||||
run(HOST, (
|
||||
f"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
||||
f"curl -sS -X POST 'http://127.0.0.1:8000/api/v1/applications/{app_uuid}/envs' "
|
||||
f"-H \"Authorization: Bearer $TOKEN\" "
|
||||
f"-H 'Content-Type: application/json' "
|
||||
f"-d '{{\"key\":\"{key}\",\"value\":\"{val}\"}}'"
|
||||
))
|
||||
|
||||
print("=== Deploy ===")
|
||||
run(HOST, (
|
||||
f"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
||||
f"curl -sS -X POST 'http://127.0.0.1:8000/api/v1/deploy?uuid={app_uuid}&force_rebuild=true' "
|
||||
f"-H \"Authorization: Bearer $TOKEN\""
|
||||
))
|
||||
|
||||
print("\n=== DONE ===")
|
||||
print(f"Gitea: https://gitea.onsethost.com/localadministrator/{REPO}")
|
||||
print(f"Coolify app UUID: {app_uuid or 'FAILED — create manually'}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user