chore: Refactor Gitea deployment workflow for PostgreSQL and Redis management
All checks were successful
Dev Deployment (Zero Downtime) / deploy-dev (push) Successful in 14m57s
All checks were successful
Dev Deployment (Zero Downtime) / deploy-dev (push) Successful in 14m57s
- Improved container management by stopping and removing existing containers before starting new ones to ensure a clean environment. - Added logic to remove old images and pull new ones to match the current architecture. - Enhanced feedback messages for better clarity during the deployment process.
This commit is contained in:
@@ -61,23 +61,22 @@ jobs:
|
||||
echo "🗄️ Starting database and Redis..."
|
||||
COMPOSE_FILE="docker-compose.dev.minimal.yml"
|
||||
|
||||
# Check if DB container exists
|
||||
if ! docker ps -a --format "{{.Names}}" | grep -q "portfolio_postgres_dev"; then
|
||||
echo "📦 Starting PostgreSQL container..."
|
||||
docker compose -f $COMPOSE_FILE up -d postgres
|
||||
else
|
||||
echo "✅ PostgreSQL container exists, ensuring it's running..."
|
||||
docker start portfolio_postgres_dev 2>/dev/null || docker compose -f $COMPOSE_FILE up -d postgres
|
||||
fi
|
||||
# Stop and remove existing containers to ensure clean start with correct architecture
|
||||
echo "🧹 Cleaning up existing containers..."
|
||||
docker stop portfolio_postgres_dev portfolio_redis_dev 2>/dev/null || true
|
||||
docker rm portfolio_postgres_dev portfolio_redis_dev 2>/dev/null || true
|
||||
|
||||
# Check if Redis container exists
|
||||
if ! docker ps -a --format "{{.Names}}" | grep -q "portfolio_redis_dev"; then
|
||||
echo "📦 Starting Redis container..."
|
||||
docker compose -f $COMPOSE_FILE up -d redis
|
||||
else
|
||||
echo "✅ Redis container exists, ensuring it's running..."
|
||||
docker start portfolio_redis_dev 2>/dev/null || docker compose -f $COMPOSE_FILE up -d redis
|
||||
fi
|
||||
# Remove old images to force re-pull with correct architecture
|
||||
echo "🔄 Removing old images to force re-pull..."
|
||||
docker rmi postgres:15-alpine redis:7-alpine 2>/dev/null || true
|
||||
|
||||
# Pull images with correct architecture (Docker will auto-detect)
|
||||
echo "📥 Pulling images for current architecture..."
|
||||
docker compose -f $COMPOSE_FILE pull postgres redis
|
||||
|
||||
# Start containers
|
||||
echo "📦 Starting PostgreSQL and Redis containers..."
|
||||
docker compose -f $COMPOSE_FILE up -d postgres redis
|
||||
|
||||
# Wait for DB to be ready
|
||||
echo "⏳ Waiting for database to be ready..."
|
||||
|
||||
Reference in New Issue
Block a user