fix: Postgres Fixes for Prod
All checks were successful
Deploy to Staging / Build Images (push) Successful in 1m34s
Deploy to Staging / Deploy to Staging (push) Successful in 23s
Deploy to Staging / Verify Staging (push) Successful in 2m36s
Deploy to Staging / Notify Staging Ready (push) Successful in 8s
Deploy to Staging / Notify Staging Failure (push) Has been skipped

This commit is contained in:
Eric Gullickson
2026-02-08 20:57:49 -06:00
parent 8248b1a732
commit c6b99ab29a
4 changed files with 32 additions and 11 deletions

View File

@@ -22,7 +22,7 @@ env:
BASE_COMPOSE_FILE: docker-compose.yml
COMPOSE_BLUE_GREEN: docker-compose.blue-green.yml
COMPOSE_PROD: docker-compose.prod.yml
HEALTH_CHECK_TIMEOUT: "60"
HEALTH_CHECK_TIMEOUT: "240"
LOG_LEVEL: INFO
jobs:
@@ -169,10 +169,32 @@ jobs:
run: |
cd "$DEPLOY_PATH"
# Start shared infrastructure services (database, cache, logging)
# These persist across blue-green deployments
docker compose -f $BASE_COMPOSE_FILE -f $COMPOSE_BLUE_GREEN -f $COMPOSE_PROD up -d \
# --no-recreate prevents restarting postgres/redis when config files change
# These must persist across blue-green deployments to avoid data service disruption
docker compose -f $BASE_COMPOSE_FILE -f $COMPOSE_BLUE_GREEN -f $COMPOSE_PROD up -d --no-recreate \
mvp-postgres mvp-redis mvp-loki mvp-alloy mvp-grafana
- name: Wait for shared services health
run: |
echo "Waiting for PostgreSQL and Redis to be healthy..."
for service in mvp-postgres mvp-redis; do
for i in $(seq 1 24); do
health=$(docker inspect --format='{{.State.Health.Status}}' $service 2>/dev/null || echo "unknown")
if [ "$health" = "healthy" ]; then
echo "OK: $service is healthy"
break
fi
if [ $i -eq 24 ]; then
echo "ERROR: $service health check timed out (status: $health)"
docker logs $service --tail 50 2>/dev/null || true
exit 1
fi
echo "Waiting for $service... (attempt $i/24, status: $health)"
sleep 5
done
done
echo "All shared services healthy"
- name: Start target stack
run: |
cd "$DEPLOY_PATH"

View File

@@ -61,7 +61,7 @@ services:
LOG_LEVEL: error
POSTGRES_LOG_STATEMENT: none
POSTGRES_LOG_MIN_DURATION_STATEMENT: -1
PGDATA: /var/lib/postgresql/data
PGDATA: /var/lib/postgresql/data/pgdata
# Redis - Remove dev ports, production log level
mvp-redis:

View File

@@ -233,7 +233,7 @@ services:
LOG_LEVEL: debug
POSTGRES_LOG_STATEMENT: all
POSTGRES_LOG_MIN_DURATION_STATEMENT: 0
PGDATA: /var/lib/postgresql/data
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- mvp_postgres_data:/var/lib/postgresql/data
# Secrets (K8s Secrets equivalent)

View File

@@ -92,19 +92,18 @@ wait_for_health() {
if [[ $status -eq 0 ]]; then
return 0
elif [[ $status -eq 1 ]]; then
echo " ERROR: Container $container is unhealthy"
docker logs "$container" --tail 20 2>/dev/null || true
return 1
fi
# Still starting, wait
# Both "starting" and "unhealthy" are treated as transient during the wait period.
# Docker can report "unhealthy" briefly during start_period before the next check
# cycle transitions it back. Only the overall timeout should cause failure.
sleep 2
elapsed=$((elapsed + 2))
echo " Waiting for $container... (${elapsed}s/${TIMEOUT}s)"
done
echo " ERROR: Timeout waiting for $container"
echo " ERROR: Container $container did not become healthy within ${TIMEOUT}s"
docker logs "$container" --tail 20 2>/dev/null || true
return 1
}