Fix container conflicts and environment variables
- Add comprehensive container cleanup before starting services - Pass environment variables to docker compose commands - Fix container name conflicts by removing all existing containers first - Add local test script to verify deployment process - Ensure clean environment for zero-downtime deployments
This commit is contained in:
@@ -67,12 +67,28 @@ jobs:
|
|||||||
CURRENT_CONTAINER_RUNNING=false
|
CURRENT_CONTAINER_RUNNING=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clean up ALL existing containers first
|
||||||
|
echo "🧹 Cleaning up ALL existing containers..."
|
||||||
|
docker compose down --remove-orphans || true
|
||||||
|
docker rm -f portfolio-app portfolio-postgres portfolio-redis || true
|
||||||
|
|
||||||
# Ensure database and redis are running
|
# Ensure database and redis are running
|
||||||
echo "🔧 Ensuring database and redis are running..."
|
echo "🔧 Ensuring database and redis are running..."
|
||||||
docker compose up -d postgres redis
|
docker compose up -d postgres redis
|
||||||
|
|
||||||
# Wait for services to be ready
|
# Wait for services to be ready
|
||||||
sleep 10
|
sleep 10
|
||||||
|
env:
|
||||||
|
NODE_ENV: ${{ vars.NODE_ENV }}
|
||||||
|
LOG_LEVEL: ${{ vars.LOG_LEVEL }}
|
||||||
|
NEXT_PUBLIC_BASE_URL: ${{ vars.NEXT_PUBLIC_BASE_URL }}
|
||||||
|
NEXT_PUBLIC_UMAMI_URL: ${{ vars.NEXT_PUBLIC_UMAMI_URL }}
|
||||||
|
NEXT_PUBLIC_UMAMI_WEBSITE_ID: ${{ vars.NEXT_PUBLIC_UMAMI_WEBSITE_ID }}
|
||||||
|
MY_EMAIL: ${{ vars.MY_EMAIL }}
|
||||||
|
MY_INFO_EMAIL: ${{ vars.MY_INFO_EMAIL }}
|
||||||
|
MY_PASSWORD: ${{ secrets.MY_PASSWORD }}
|
||||||
|
MY_INFO_PASSWORD: ${{ secrets.MY_INFO_PASSWORD }}
|
||||||
|
ADMIN_BASIC_AUTH: ${{ secrets.ADMIN_BASIC_AUTH }}
|
||||||
|
|
||||||
- name: Verify secrets and variables before deployment
|
- name: Verify secrets and variables before deployment
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
36
test-deployment.sh
Executable file
36
test-deployment.sh
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Test script for deployment issues
|
||||||
|
echo "🧪 Testing deployment locally..."
|
||||||
|
|
||||||
|
# Set test environment variables
|
||||||
|
export NODE_ENV=production
|
||||||
|
export LOG_LEVEL=info
|
||||||
|
export NEXT_PUBLIC_BASE_URL=https://dk0.dev
|
||||||
|
export NEXT_PUBLIC_UMAMI_URL=https://analytics.dk0.dev
|
||||||
|
export NEXT_PUBLIC_UMAMI_WEBSITE_ID=b3665829-927a-4ada-b9bb-fcf24171061e
|
||||||
|
export MY_EMAIL=contact@dk0.dev
|
||||||
|
export MY_INFO_EMAIL=info@dk0.dev
|
||||||
|
export MY_PASSWORD=test_password
|
||||||
|
export MY_INFO_PASSWORD=test_info_password
|
||||||
|
export ADMIN_BASIC_AUTH=admin:test_password
|
||||||
|
|
||||||
|
echo "🔧 Environment variables set:"
|
||||||
|
echo "NODE_ENV: $NODE_ENV"
|
||||||
|
echo "NEXT_PUBLIC_BASE_URL: $NEXT_PUBLIC_BASE_URL"
|
||||||
|
echo "MY_EMAIL: $MY_EMAIL"
|
||||||
|
|
||||||
|
echo "🧹 Cleaning up existing containers..."
|
||||||
|
docker compose down --remove-orphans || true
|
||||||
|
docker rm -f portfolio-app portfolio-postgres portfolio-redis || true
|
||||||
|
|
||||||
|
echo "🔧 Starting database and redis..."
|
||||||
|
docker compose up -d postgres redis
|
||||||
|
|
||||||
|
echo "⏳ Waiting for services to be ready..."
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
echo "📋 Checking running containers:"
|
||||||
|
docker ps --format "table {{.Names}}\t{{.Status}}"
|
||||||
|
|
||||||
|
echo "✅ Test completed!"
|
||||||
Reference in New Issue
Block a user