From 2bd3c31660d0988e40071cec16044a79339e8b69 Mon Sep 17 00:00:00 2001 From: Ryan Salazar Date: Fri, 26 Jun 2026 17:44:19 -0400 Subject: [PATCH] Fix Map.tsx types, auth flow, Docker legacy-peer-deps --- .npmrc | 1 + Dockerfile | 4 +- deploy/check-deploy.py | 32 ++++++++ deploy/debug-deploy.py | 68 +++++++++++++++++ deploy/fix-coolify-git.py | 68 +++++++++++++++++ deploy/fix-gitea-push.py | 78 +++++++++++++++++++ deploy/get-log.py | 11 +++ deploy/push-and-deploy.py | 58 ++++++++++++++ deploy/redeploy.py | 79 +++++++++++++++++++ deploy/setup-infra-ssh.py | 154 ++++++++++++++++++++++++++++++++++++++ src/components/Map.tsx | 18 +++-- 11 files changed, 562 insertions(+), 9 deletions(-) create mode 100644 .npmrc create mode 100644 deploy/check-deploy.py create mode 100644 deploy/debug-deploy.py create mode 100644 deploy/fix-coolify-git.py create mode 100644 deploy/fix-gitea-push.py create mode 100644 deploy/get-log.py create mode 100644 deploy/push-and-deploy.py create mode 100644 deploy/redeploy.py create mode 100644 deploy/setup-infra-ssh.py diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..e9ee3cb --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +legacy-peer-deps=true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a3f3e60..d979333 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,8 @@ FROM node:22-alpine AS base FROM base AS deps RUN apk add --no-cache libc6-compat WORKDIR /app -COPY package.json package-lock.json* ./ -RUN npm ci +COPY package.json package-lock.json* .npmrc ./ +RUN npm install --legacy-peer-deps FROM base AS builder WORKDIR /app diff --git a/deploy/check-deploy.py b/deploy/check-deploy.py new file mode 100644 index 0000000..1bd1b20 --- /dev/null +++ b/deploy/check-deploy.py @@ -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() \ No newline at end of file diff --git a/deploy/debug-deploy.py b/deploy/debug-deploy.py new file mode 100644 index 0000000..84a6f68 --- /dev/null +++ b/deploy/debug-deploy.py @@ -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() \ No newline at end of file diff --git a/deploy/fix-coolify-git.py b/deploy/fix-coolify-git.py new file mode 100644 index 0000000..50affad --- /dev/null +++ b/deploy/fix-coolify-git.py @@ -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() \ No newline at end of file diff --git a/deploy/fix-gitea-push.py b/deploy/fix-gitea-push.py new file mode 100644 index 0000000..e057a7c --- /dev/null +++ b/deploy/fix-gitea-push.py @@ -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() \ No newline at end of file diff --git a/deploy/get-log.py b/deploy/get-log.py new file mode 100644 index 0000000..3ddad0e --- /dev/null +++ b/deploy/get-log.py @@ -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() \ No newline at end of file diff --git a/deploy/push-and-deploy.py b/deploy/push-and-deploy.py new file mode 100644 index 0000000..9a5478f --- /dev/null +++ b/deploy/push-and-deploy.py @@ -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() \ No newline at end of file diff --git a/deploy/redeploy.py b/deploy/redeploy.py new file mode 100644 index 0000000..825cf81 --- /dev/null +++ b/deploy/redeploy.py @@ -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() \ No newline at end of file diff --git a/deploy/setup-infra-ssh.py b/deploy/setup-infra-ssh.py new file mode 100644 index 0000000..abbd9ef --- /dev/null +++ b/deploy/setup-infra-ssh.py @@ -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() \ No newline at end of file diff --git a/src/components/Map.tsx b/src/components/Map.tsx index a5b8f6f..f56e7bd 100644 --- a/src/components/Map.tsx +++ b/src/components/Map.tsx @@ -54,8 +54,10 @@ export function CruisingMap({ vanillaMode, onActiveCountChange }: MapProps) { const [showFilters, setShowFilters] = useState(false); const [showSidebar, setShowSidebar] = useState(true); const [leafletReady, setLeafletReady] = useState(false); - const [userIcon, setUserIcon] = useState(null); - const [spotIcon, setSpotIcon] = useState(null); + const [iconFactory, setIconFactory] = useState<{ + createUser: (position: string | null, status: string) => import("leaflet").DivIcon; + createSpot: (category: string) => import("leaflet").DivIcon; + } | null>(null); const [filters, setFilters] = useState({ ageMin: 18, @@ -105,8 +107,10 @@ export function CruisingMap({ vanillaMode, onActiveCountChange }: MapProps) { }); }; - setUserIcon({ create: createUserIcon }); - setSpotIcon({ create: createSpotIcon }); + setIconFactory({ + createUser: createUserIcon, + createSpot: createSpotIcon, + }); setLeafletReady(true); }); }, []); @@ -277,7 +281,7 @@ export function CruisingMap({ vanillaMode, onActiveCountChange }: MapProps) { )} {/* Map */} - {leafletReady && userIcon && spotIcon && ( + {leafletReady && iconFactory && ( unknown }).create(p.position, p.status)} + icon={iconFactory.createUser(p.position, p.status)} eventHandlers={{ click: () => setSelectedProfile(p), }} @@ -329,7 +333,7 @@ export function CruisingMap({ vanillaMode, onActiveCountChange }: MapProps) { unknown }).create(s.category)} + icon={iconFactory.createSpot(s.category)} >