Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 27s
- Get default gateway IP from routing table - Test connection to DIND on gateway - Provide instructions if connection fails - Network isolation might need runner configuration fix 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
67 lines
2.2 KiB
YAML
67 lines
2.2 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: docker:latest
|
|
|
|
steps:
|
|
- name: Debug network configuration
|
|
run: |
|
|
echo "=== Network interfaces and routes ==="
|
|
ip route show 2>/dev/null || route -n
|
|
|
|
echo ""
|
|
echo "=== Testing gateway IP directly ==="
|
|
GATEWAY_IP=$(ip route show | grep default | awk '{print $3}')
|
|
echo "Gateway IP: $GATEWAY_IP"
|
|
|
|
if timeout 2 sh -c "cat < /dev/null > /dev/tcp/$GATEWAY_IP/2375" 2>/dev/null; then
|
|
echo "✅ Can reach DIND at $GATEWAY_IP:2375"
|
|
echo "DOCKER_HOST=tcp://$GATEWAY_IP:2375" >> $GITHUB_ENV
|
|
export DOCKER_HOST=tcp://$GATEWAY_IP:2375
|
|
else
|
|
echo "❌ Cannot reach gateway at $GATEWAY_IP:2375"
|
|
echo "The DIND container might not be accessible from job containers"
|
|
echo "You may need to configure the runner to use --network=host or expose DIND port on host"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Verify Docker connection
|
|
run: |
|
|
docker version
|
|
|
|
- name: Checkout repository
|
|
run: |
|
|
apk add --no-cache git
|
|
git clone ${{ github.server_url }}/${{ github.repository }} .
|
|
git checkout ${{ github.sha }}
|
|
ls -la
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build \
|
|
-t forgejo.sivic.me/${{ github.repository }}:latest \
|
|
-t forgejo.sivic.me/${{ github.repository }}:${{ github.sha }} \
|
|
.
|
|
|
|
- name: Log in to Forgejo Container Registry
|
|
run: |
|
|
echo "${{ secrets.GITEA_TOKEN }}" | docker login forgejo.sivic.me -u ${{ github.actor }} --password-stdin
|
|
|
|
- name: Push Docker images
|
|
run: |
|
|
docker push forgejo.sivic.me/${{ github.repository }}:latest
|
|
docker push forgejo.sivic.me/${{ github.repository }}:${{ github.sha }}
|
|
|
|
- name: Summary
|
|
run: |
|
|
echo "✅ Successfully built and pushed:"
|
|
echo " - forgejo.sivic.me/${{ github.repository }}:latest"
|
|
echo " - forgejo.sivic.me/${{ github.repository }}:${{ github.sha }}"
|