fix(deploy): dynamically find a free PostgREST host port
Deploy to route.crispygoat.com / deploy (push) Failing after 13s
Build / build (push) Has been cancelled

Previous attempts hardcoded 3011, but something on tyler's host is
holding 3011 too. Instead of guessing ports, make the deploy probe
for the first free port starting from 3011 and thread that choice
through the rest of the workflow.

How it works:
1. Start Docker stack frees 3001 + the previous deploy's chosen port
   (read from .postgrest-port) so the lowest free port can be picked
   back up
2. Loops from 3011 upward, checking ss -tln until it finds a free
   port in the 3011-30200 range
3. Writes the chosen port to .postgrest-port in the workspace
4. Sets NEXT_PUBLIC_API_URL based on that port
5. Writes POSTGREST_HOST_PORT and NEXT_PUBLIC_API_URL to the .env
   that docker compose reads
6. Build and Deploy steps read .postgrest-port to set their
   NEXT_PUBLIC_API_URL dynamically — no more hardcoded 3011
This commit is contained in:
2026-06-06 00:12:23 +00:00
parent 9759dd042e
commit ffed10cd66
2 changed files with 40 additions and 13 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ services:
PGRST_OPENAPI_MODE: disabled
PGRST_DB_EXTRA_SEARCH_PATH: public,extensions
ports:
- "127.0.0.1:3011:3001"
- "127.0.0.1:${POSTGREST_HOST_PORT:-3011}:3001"
minio:
image: minio/minio:latest