fix: isolate prod deploy from dev env port conflict
All checks were successful
CI / Lint, type check, unit tests, coverage (push) Successful in 1m50s
CI / E2E browser tests (push) Successful in 47s

The production deploy failed because port 3000 was already bound by the
dev frontend container (bilhej-frontend). The prod frontend doesn't need
a host port at all — nginx talks to it via the external 'web' network.

Changes:
- Remove host port binding (3000:80) from prod frontend
- Remove unused 'certs' volume from prod compose
- Use --project-name bilhej-prod in deploy workflow to isolate prod
  containers/networks from dev and e2e environments
- Add 'docker compose down' before 'up' for clean deploys
- Update health check network names to bilhej-prod_default
This commit is contained in:
Joakim Mörling 2026-05-20 12:45:08 +02:00
parent d078b9e125
commit dfcc8e37c6
2 changed files with 5 additions and 9 deletions

View file

@ -42,7 +42,8 @@ jobs:
- name: Build and start production stack - name: Build and start production stack
run: | run: |
docker compose -f docker-compose.prod.yml up --build -d docker compose -p bilhej-prod -f docker-compose.prod.yml down
docker compose -p bilhej-prod -f docker-compose.prod.yml up --build -d
- name: Wait for services - name: Wait for services
run: sleep 20 run: sleep 20
@ -50,7 +51,7 @@ jobs:
- name: Health check — backend API - name: Health check — backend API
run: | run: |
for i in 1 2 3 4 5; do for i in 1 2 3 4 5; do
if docker run --rm --network bilhej_default curlimages/curl:8.5.0 \ if docker run --rm --network bilhej-prod_default curlimages/curl:8.5.0 \
-sf http://bilhej-backend-prod:8080/api/vehicles/ZZZ999; then -sf http://bilhej-backend-prod:8080/api/vehicles/ZZZ999; then
echo "Backend is healthy" echo "Backend is healthy"
exit 0 exit 0
@ -64,7 +65,7 @@ jobs:
- name: Health check — frontend - name: Health check — frontend
run: | run: |
for i in 1 2 3 4 5; do for i in 1 2 3 4 5; do
if docker run --rm --network bilhej_default curlimages/curl:8.5.0 \ if docker run --rm --network bilhej-prod_default curlimages/curl:8.5.0 \
-sf http://bilhej-frontend-prod/ | grep -qi "bilhej\|Bilhej\|BilHej"; then -sf http://bilhej-frontend-prod/ | grep -qi "bilhej\|Bilhej\|BilHej"; then
echo "Frontend is serving" echo "Frontend is serving"
exit 0 exit 0
@ -82,7 +83,7 @@ jobs:
echo " Deployed ${{ github.event.inputs.version }} to production" echo " Deployed ${{ github.event.inputs.version }} to production"
echo "═══════════════════════════════════════════════════" echo "═══════════════════════════════════════════════════"
echo "" echo ""
docker compose -f docker-compose.prod.yml ps docker compose -p bilhej-prod -f docker-compose.prod.yml ps
echo "" echo ""
echo "Containers running. Update nginx config on srvr.nu" echo "Containers running. Update nginx config on srvr.nu"
echo "to point bilhej.se to the frontend container." echo "to point bilhej.se to the frontend container."

View file

@ -39,12 +39,8 @@ services:
dockerfile: docker/frontend.prod.Dockerfile dockerfile: docker/frontend.prod.Dockerfile
context: . context: .
container_name: bilhej-frontend-prod container_name: bilhej-frontend-prod
ports:
- "3000:80"
depends_on: depends_on:
- backend - backend
volumes:
- certs:/etc/nginx/certs
networks: networks:
- default - default
- web - web
@ -52,7 +48,6 @@ services:
volumes: volumes:
pgdata-prod: pgdata-prod:
certs:
networks: networks:
web: web: