From 30d0e597c227b17bdaa49cb846a5ccda3fbcdd68 Mon Sep 17 00:00:00 2001 From: denshooter Date: Wed, 4 Mar 2026 15:09:04 +0100 Subject: [PATCH] fix: use production DB/Redis for dev deployment instead of non-existent dev containers The dev-deploy workflow was trying to spin up separate portfolio_postgres_dev and portfolio_redis_dev containers, which don't exist on the server. Now it reuses the existing production portfolio-postgres and portfolio-redis on the portfolio_net network. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .gitea/workflows/dev-deploy.yml.disabled | 54 +++++++----------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/.gitea/workflows/dev-deploy.yml.disabled b/.gitea/workflows/dev-deploy.yml.disabled index bc7904b..06d3d26 100644 --- a/.gitea/workflows/dev-deploy.yml.disabled +++ b/.gitea/workflows/dev-deploy.yml.disabled @@ -57,49 +57,27 @@ jobs: # Check for existing container (running or stopped) EXISTING_CONTAINER=$(docker ps -aq -f name=$CONTAINER_NAME || echo "") - # Start DB and Redis if not running - echo "๐Ÿ—„๏ธ Starting database and Redis..." - COMPOSE_FILE="docker-compose.dev.minimal.yml" + # Reuse production PostgreSQL and Redis (no separate dev instances needed) + echo "๐Ÿ—„๏ธ Verifying production database and Redis are running..." - # 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 - - # Remove old images to force re-pull with correct architecture - echo "๐Ÿ”„ Removing old images to force re-pull..." - docker rmi postgres:16-alpine redis:7-alpine 2>/dev/null || true - - # Ensure networks exist before compose starts (network is external) + # Ensure networks exist echo "๐ŸŒ Ensuring networks exist..." - docker network create portfolio_dev 2>/dev/null || true + docker network create portfolio_net 2>/dev/null || true docker network create proxy 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 + # Verify production DB is reachable + if docker exec portfolio-postgres pg_isready -U portfolio_user -d portfolio_db >/dev/null 2>&1; then + echo "โœ… Production database is ready!" + else + echo "โš ๏ธ Production database not reachable, app will use fallbacks" + fi - # Wait for DB to be ready - echo "โณ Waiting for database to be ready..." - for i in {1..30}; do - if docker exec portfolio_postgres_dev pg_isready -U portfolio_user -d portfolio_dev >/dev/null 2>&1; then - echo "โœ… Database is ready!" - break - fi - echo "โณ Waiting for database... ($i/30)" - sleep 1 - done - - # Export environment variables + # Export environment variables (pointing to production DB/Redis) export NODE_ENV=production export LOG_LEVEL=${LOG_LEVEL:-debug} export NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL_DEV:-https://dev.dk0.dev} - export DATABASE_URL="postgresql://portfolio_user:portfolio_dev_pass@portfolio_postgres_dev:5432/portfolio_dev?schema=public" - export REDIS_URL="redis://portfolio_redis_dev:6379" + export DATABASE_URL="postgresql://portfolio_user:portfolio_pass@portfolio-postgres:5432/portfolio_db?schema=public" + export REDIS_URL="redis://portfolio-redis:6379" export MY_EMAIL=${MY_EMAIL} export MY_INFO_EMAIL=${MY_INFO_EMAIL} export MY_PASSWORD=${MY_PASSWORD} @@ -202,7 +180,7 @@ jobs: docker run -d \ --name $CONTAINER_NAME \ --restart unless-stopped \ - --network portfolio_dev \ + --network portfolio_net \ -p ${HEALTH_PORT}:3000 \ -e NODE_ENV=production \ -e LOG_LEVEL=${LOG_LEVEL:-debug} \ @@ -268,8 +246,8 @@ jobs: NODE_ENV: production LOG_LEVEL: ${{ vars.LOG_LEVEL || 'debug' }} NEXT_PUBLIC_BASE_URL_DEV: ${{ vars.NEXT_PUBLIC_BASE_URL_DEV || 'https://dev.dk0.dev' }} - DATABASE_URL: postgresql://portfolio_user:portfolio_dev_pass@portfolio_postgres_dev:5432/portfolio_dev?schema=public - REDIS_URL: redis://portfolio_redis_dev:6379 + DATABASE_URL: postgresql://portfolio_user:portfolio_pass@portfolio-postgres:5432/portfolio_db?schema=public + REDIS_URL: redis://portfolio-redis:6379 MY_EMAIL: ${{ vars.MY_EMAIL }} MY_INFO_EMAIL: ${{ vars.MY_INFO_EMAIL }} MY_PASSWORD: ${{ secrets.MY_PASSWORD }}