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
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:
@@ -22,7 +22,7 @@ env:
|
|||||||
BASE_COMPOSE_FILE: docker-compose.yml
|
BASE_COMPOSE_FILE: docker-compose.yml
|
||||||
COMPOSE_BLUE_GREEN: docker-compose.blue-green.yml
|
COMPOSE_BLUE_GREEN: docker-compose.blue-green.yml
|
||||||
COMPOSE_PROD: docker-compose.prod.yml
|
COMPOSE_PROD: docker-compose.prod.yml
|
||||||
HEALTH_CHECK_TIMEOUT: "60"
|
HEALTH_CHECK_TIMEOUT: "240"
|
||||||
LOG_LEVEL: INFO
|
LOG_LEVEL: INFO
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -169,10 +169,32 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd "$DEPLOY_PATH"
|
cd "$DEPLOY_PATH"
|
||||||
# Start shared infrastructure services (database, cache, logging)
|
# Start shared infrastructure services (database, cache, logging)
|
||||||
# These persist across blue-green deployments
|
# --no-recreate prevents restarting postgres/redis when config files change
|
||||||
docker compose -f $BASE_COMPOSE_FILE -f $COMPOSE_BLUE_GREEN -f $COMPOSE_PROD up -d \
|
# 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
|
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
|
- name: Start target stack
|
||||||
run: |
|
run: |
|
||||||
cd "$DEPLOY_PATH"
|
cd "$DEPLOY_PATH"
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ services:
|
|||||||
LOG_LEVEL: error
|
LOG_LEVEL: error
|
||||||
POSTGRES_LOG_STATEMENT: none
|
POSTGRES_LOG_STATEMENT: none
|
||||||
POSTGRES_LOG_MIN_DURATION_STATEMENT: -1
|
POSTGRES_LOG_MIN_DURATION_STATEMENT: -1
|
||||||
PGDATA: /var/lib/postgresql/data
|
PGDATA: /var/lib/postgresql/data/pgdata
|
||||||
|
|
||||||
# Redis - Remove dev ports, production log level
|
# Redis - Remove dev ports, production log level
|
||||||
mvp-redis:
|
mvp-redis:
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ services:
|
|||||||
LOG_LEVEL: debug
|
LOG_LEVEL: debug
|
||||||
POSTGRES_LOG_STATEMENT: all
|
POSTGRES_LOG_STATEMENT: all
|
||||||
POSTGRES_LOG_MIN_DURATION_STATEMENT: 0
|
POSTGRES_LOG_MIN_DURATION_STATEMENT: 0
|
||||||
PGDATA: /var/lib/postgresql/data
|
PGDATA: /var/lib/postgresql/data/pgdata
|
||||||
volumes:
|
volumes:
|
||||||
- mvp_postgres_data:/var/lib/postgresql/data
|
- mvp_postgres_data:/var/lib/postgresql/data
|
||||||
# Secrets (K8s Secrets equivalent)
|
# Secrets (K8s Secrets equivalent)
|
||||||
|
|||||||
@@ -92,19 +92,18 @@ wait_for_health() {
|
|||||||
|
|
||||||
if [[ $status -eq 0 ]]; then
|
if [[ $status -eq 0 ]]; then
|
||||||
return 0
|
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
|
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
|
sleep 2
|
||||||
elapsed=$((elapsed + 2))
|
elapsed=$((elapsed + 2))
|
||||||
echo " Waiting for $container... (${elapsed}s/${TIMEOUT}s)"
|
echo " Waiting for $container... (${elapsed}s/${TIMEOUT}s)"
|
||||||
done
|
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
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user