From 21572d8873440e979ae668089d856e678b9210f0 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 5 Mar 2026 10:04:56 -0600 Subject: [PATCH] fix: use service hostname instead of localhost for PostgreSQL - Remove port mapping (5432:5432) to avoid port conflicts on runner - Use 'postgres' hostname instead of 'localhost' to access service - Service containers in Actions are accessible via their service name - Fixes 'port is already allocated' error on self-hosted runners --- .forgejo/workflows/build.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index c0fb2614..08d89ba3 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -28,8 +28,6 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 - ports: - - 5432:5432 steps: - name: Checkout code @@ -78,7 +76,7 @@ jobs: - name: Wait for PostgreSQL run: | - until pg_isready -h localhost -p 5432 -U postgres; do + until pg_isready -h postgres -p 5432 -U postgres; do echo "Waiting for PostgreSQL..." sleep 2 done @@ -88,7 +86,7 @@ jobs: run: mix ecto.create env: MIX_ENV: test - DATABASE_URL: postgresql://postgres:postgres@localhost:5432/towerops_test + DATABASE_URL: postgresql://postgres:postgres@postgres:5432/towerops_test - name: Check code formatting run: mix format --check-formatted @@ -105,7 +103,7 @@ jobs: run: mix test --warnings-as-errors env: MIX_ENV: test - DATABASE_URL: postgresql://postgres:postgres@localhost:5432/towerops_test + DATABASE_URL: postgresql://postgres:postgres@postgres:5432/towerops_test build: runs-on: ubuntu-22.04