🔧 Update Next.js configuration and enhance Gitea deployment script
Some checks failed
CI/CD Pipeline (Fast) / production (push) Failing after 5m1s
CI/CD Pipeline (Zero Downtime - Fixed) / production (push) Has been cancelled

- Added serverRuntimeConfig to next.config.ts for improved server-side configuration.
- Updated gitea-deploy.sh to include additional environment variables for deployment.
- Increased sleep duration and health check timeout for better container readiness verification.
- Implemented checks to ensure the container is running during health checks and logs container status if it fails.

 Enhancements improve deployment reliability and server configuration management.
This commit is contained in:
2025-09-13 23:37:53 +02:00
parent 116dac89b3
commit cc5009a0d6
4 changed files with 280 additions and 13 deletions

View File

@@ -122,13 +122,20 @@ else
DEPLOY_PORT=$PORT
fi
# Start new container
# Start new container with environment variables
log "🚀 Starting new container on port $DEPLOY_PORT..."
docker run -d \
--name "$CONTAINER_NAME" \
--restart unless-stopped \
-p "$DEPLOY_PORT:3000" \
-e NODE_ENV=production \
-e NEXT_PUBLIC_BASE_URL=https://dk0.dev \
-e MY_EMAIL=contact@dk0.dev \
-e MY_INFO_EMAIL=info@dk0.dev \
-e MY_PASSWORD="${MY_PASSWORD:-your-email-password}" \
-e MY_INFO_PASSWORD="${MY_INFO_PASSWORD:-your-info-email-password}" \
-e ADMIN_BASIC_AUTH="${ADMIN_BASIC_AUTH:-admin:your_secure_password_here}" \
-e LOG_LEVEL=info \
"$IMAGE_NAME:latest" || {
error "Failed to start container"
exit 1
@@ -136,15 +143,32 @@ docker run -d \
# Wait for container to be ready
log "⏳ Waiting for container to be ready..."
sleep 10
sleep 15
# Check if container is actually running
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null)" != "true" ]; then
error "Container failed to start or crashed"
log "Container logs:"
docker logs "$CONTAINER_NAME" --tail=50
exit 1
fi
# Health check
log "🏥 Performing health check..."
HEALTH_CHECK_TIMEOUT=60
HEALTH_CHECK_INTERVAL=2
HEALTH_CHECK_TIMEOUT=120
HEALTH_CHECK_INTERVAL=3
ELAPSED=0
while [ $ELAPSED -lt $HEALTH_CHECK_TIMEOUT ]; do
# Check if container is still running
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null)" != "true" ]; then
error "Container stopped during health check"
log "Container logs:"
docker logs "$CONTAINER_NAME" --tail=50
exit 1
fi
# Try health check endpoint
if curl -f "http://localhost:$DEPLOY_PORT/api/health" > /dev/null 2>&1; then
success "✅ Application is healthy!"
break
@@ -157,8 +181,10 @@ done
if [ $ELAPSED -ge $HEALTH_CHECK_TIMEOUT ]; then
error "Health check timeout. Application may not be running properly."
log "Container status:"
docker inspect "$CONTAINER_NAME" --format='{{.State.Status}} - {{.State.Health.Status}}'
log "Container logs:"
docker logs "$CONTAINER_NAME" --tail=50
docker logs "$CONTAINER_NAME" --tail=100
exit 1
fi