Make Docker mandatory for pre-push hook
Some checks failed
CI/CD Pipeline (Simple) / test-and-build (push) Has been skipped
CI/CD Pipeline (Simple) / production (push) Failing after 7m53s

- Docker must be running and functional before push is allowed
- Added comprehensive Docker status checks (info + hello-world test)
- Enhanced error messages with platform-specific Docker start instructions
- Improved build error reporting with detailed log output
- Added common troubleshooting tips for Docker build failures
- Push will fail if Docker is not available or build fails
This commit is contained in:
2025-09-12 23:36:42 +02:00
parent 7f6694622c
commit 5a14efb5fc

View File

@@ -139,20 +139,52 @@ if [ "$CURRENT_BRANCH" = "production" ]; then
print_warning "No .env file found. Make sure secrets are configured in Gitea."
fi
# Check if Docker is running
# Check if Docker is running and ready
print_status "Checking Docker status..."
if ! docker info > /dev/null 2>&1; then
print_warning "Docker is not running. Skipping Docker build test."
print_error "Docker is not running! Please start Docker before pushing."
print_status "To start Docker:"
print_status " - macOS: Open Docker Desktop application"
print_status " - Linux: sudo systemctl start docker"
print_status " - Windows: Start Docker Desktop application"
print_status ""
print_status "Wait for Docker to fully start before trying again."
exit 1
fi
# Test Docker functionality
if ! docker run --rm hello-world > /dev/null 2>&1; then
print_error "Docker is running but not functional!"
print_status "Docker might still be starting up. Please wait and try again."
print_status "Or restart Docker if the issue persists."
exit 1
fi
print_success "Docker is running and functional"
# Check Docker image can be built
print_status "Testing Docker build..."
# Create a temporary log file for build output
BUILD_LOG=$(mktemp)
if docker build -t portfolio-app:test . > "$BUILD_LOG" 2>&1; then
print_success "Docker build test passed"
docker rmi portfolio-app:test > /dev/null 2>&1
rm -f "$BUILD_LOG"
else
# Check Docker image can be built
print_status "Testing Docker build..."
if docker build -t portfolio-app:test . > /dev/null 2>&1; then
print_success "Docker build test passed"
docker rmi portfolio-app:test > /dev/null 2>&1
else
print_warning "Docker build test failed, but continuing..."
# Don't fail the push for Docker build issues in pre-push hook
# The CI/CD pipeline will catch this
fi
print_error "Docker build test failed!"
print_status "Build errors:"
echo "----------------------------------------"
cat "$BUILD_LOG"
echo "----------------------------------------"
print_status "Please fix Docker build issues before pushing."
print_status "Common issues:"
print_status " - Missing files referenced in Dockerfile"
print_status " - Network issues during npm install"
print_status " - Insufficient disk space"
rm -f "$BUILD_LOG"
exit 1
fi
fi