From 019fff1d5bd7d0b23004096b82efa1b70b8ca0bc Mon Sep 17 00:00:00 2001 From: denshooter Date: Thu, 15 Jan 2026 22:20:19 +0100 Subject: [PATCH] chore: Refactor Gitea deployment workflow for PostgreSQL and Redis management - 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. --- .gitea/workflows/dev-deploy.yml | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/.gitea/workflows/dev-deploy.yml b/.gitea/workflows/dev-deploy.yml index 3a28549..c7d01e1 100644 --- a/.gitea/workflows/dev-deploy.yml +++ b/.gitea/workflows/dev-deploy.yml @@ -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..."