diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 194267a..f51aaa2 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -44,12 +44,21 @@ jobs: run: | echo "🧪 Testing container..." - # Usar nome único baseado no timestamp + # Verificar se porta 8083 está livre + echo "🔍 Checking port 8083..." + if ss -tulpn | grep :8083; then + echo "⚠️ Port 8083 is in use, stopping conflicting containers..." + docker ps --filter "publish=8083" -q | xargs -r docker stop + docker ps -a --filter "publish=8083" -q | xargs -r docker rm + sleep 2 + fi + + # Usar nome único CONTAINER_NAME="test-container-$(date +%s)" - echo "🚀 Starting test container: $CONTAINER_NAME" + echo "🚀 Starting test container: $CONTAINER_NAME on port 8083" # Iniciar container de teste - docker run -d --name $CONTAINER_NAME -p 8080:80 ${{ steps.meta.outputs.LATEST_TAG }} + docker run -d --name $CONTAINER_NAME -p 8083:80 ${{ steps.meta.outputs.LATEST_TAG }} # Aguardar inicialização echo "⏳ Waiting for container..." @@ -58,14 +67,14 @@ jobs: # Verificar se container está rodando if ! docker ps | grep $CONTAINER_NAME; then echo "❌ Container not running" - docker logs $CONTAINER_NAME + docker logs $CONTAINER_NAME 2>/dev/null || true docker stop $CONTAINER_NAME 2>/dev/null || true docker rm $CONTAINER_NAME 2>/dev/null || true exit 1 fi # Teste interno - echo "🔍 Testing nginx..." + echo "🔍 Testing nginx internally..." if docker exec $CONTAINER_NAME wget -q --spider http://localhost/; then echo "✅ Internal test passed" else @@ -76,6 +85,14 @@ jobs: exit 1 fi + # Teste externo + echo "🔍 Testing external connectivity on port 8083..." + if curl -f http://localhost:8083/ --max-time 10; then + echo "✅ External test passed" + else + echo "⚠️ External test failed (but internal passed)" + fi + # Limpeza echo "🧹 Cleaning up test container..." docker stop $CONTAINER_NAME @@ -117,19 +134,18 @@ jobs: docker stop ${{ env.CONTAINER_NAME }} || true docker rm ${{ env.CONTAINER_NAME }} || true - echo "🚀 Starting new container..." + echo "🚀 Starting new container on port 8083..." docker run -d \ --name ${{ env.CONTAINER_NAME }} \ --restart unless-stopped \ - -p 8080:80 \ + -p 8083:80 \ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest echo "🧪 Testing deployment..." sleep 5 - # Testar se está respondendo - curl -f http://localhost/ || exit 1 - curl -f http://localhost/en/ || exit 1 + # Testar se está respondendo na porta 8083 + curl -f http://localhost:8083/ || exit 1 echo "🧹 Cleaning up old images..." docker image prune -f