🔧 Enhance Gitea deployment workflows and fix nginx configuration
- Added new CI/CD workflow `ci-cd-reliable.yml` for reliable deployments with database support.
- Created `docker-compose.zero-downtime-fixed.yml` to address nginx configuration issues for zero-downtime deployments.
- Improved existing workflows to check for nginx configuration file and create a fallback if missing.
- Updated `DEPLOYMENT-FIXES.md` to document new workflows and fixes.
✅ These changes improve deployment reliability and ensure proper nginx configuration for seamless updates.
This commit is contained in:
@@ -93,13 +93,50 @@ jobs:
|
||||
export MY_INFO_PASSWORD="${{ secrets.MY_INFO_PASSWORD }}"
|
||||
export ADMIN_BASIC_AUTH="${{ secrets.ADMIN_BASIC_AUTH }}"
|
||||
|
||||
# Check if nginx config file exists
|
||||
echo "🔍 Checking nginx configuration file..."
|
||||
if [ ! -f "nginx-zero-downtime.conf" ]; then
|
||||
echo "⚠️ nginx-zero-downtime.conf not found, creating fallback..."
|
||||
cat > nginx-zero-downtime.conf << 'EOF'
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
http {
|
||||
upstream portfolio_backend {
|
||||
server portfolio-app-1:3000 max_fails=3 fail_timeout=30s;
|
||||
server portfolio-app-2:3000 max_fails=3 fail_timeout=30s;
|
||||
}
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
location / {
|
||||
proxy_pass http://portfolio_backend;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Stop old containers
|
||||
echo "🛑 Stopping old containers..."
|
||||
docker compose -f docker-compose.zero-downtime.yml down || true
|
||||
docker compose -f docker-compose.zero-downtime-fixed.yml down || true
|
||||
|
||||
# Clean up any orphaned containers
|
||||
echo "🧹 Cleaning up orphaned containers..."
|
||||
docker compose -f docker-compose.zero-downtime-fixed.yml down --remove-orphans || true
|
||||
|
||||
# Start new containers
|
||||
echo "🚀 Starting new containers..."
|
||||
docker compose -f docker-compose.zero-downtime.yml up -d
|
||||
docker compose -f docker-compose.zero-downtime-fixed.yml up -d
|
||||
|
||||
echo "✅ Zero downtime deployment completed!"
|
||||
env:
|
||||
@@ -121,7 +158,7 @@ jobs:
|
||||
|
||||
# Check if all containers are running
|
||||
echo "📊 Checking container status..."
|
||||
docker compose -f docker-compose.zero-downtime.yml ps
|
||||
docker compose -f docker-compose.zero-downtime-fixed.yml ps
|
||||
|
||||
# Wait for application containers to be healthy
|
||||
echo "🏥 Waiting for application containers to be healthy..."
|
||||
@@ -153,7 +190,7 @@ jobs:
|
||||
|
||||
# Check container status
|
||||
echo "📊 Container status:"
|
||||
docker compose -f docker-compose.zero-downtime.yml ps
|
||||
docker compose -f docker-compose.zero-downtime-fixed.yml ps
|
||||
|
||||
# Check individual application containers
|
||||
echo "🏥 Checking individual application containers..."
|
||||
@@ -203,7 +240,7 @@ jobs:
|
||||
- name: Show container status
|
||||
run: |
|
||||
echo "📊 Container status:"
|
||||
docker compose -f docker-compose.zero-downtime.yml ps
|
||||
docker compose -f docker-compose.zero-downtime-fixed.yml ps
|
||||
|
||||
- name: Cleanup old images
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user