From 71192098824c3b332e9c71af3b7aaae366bee9eb Mon Sep 17 00:00:00 2001 From: robojerk Date: Sun, 10 Aug 2025 01:17:20 -0700 Subject: [PATCH] Fix container networking: add DNS configuration and hostname resolution --- .forgejo/workflows/build-artifacts.yml | 73 +++++++++++++++----------- .forgejo/workflows/simple-build.yml | 40 +++++++++++--- 2 files changed, 74 insertions(+), 39 deletions(-) diff --git a/.forgejo/workflows/build-artifacts.yml b/.forgejo/workflows/build-artifacts.yml index 07261f8..452acb9 100644 --- a/.forgejo/workflows/build-artifacts.yml +++ b/.forgejo/workflows/build-artifacts.yml @@ -17,9 +17,9 @@ name: Build deb-bootupd Artifacts on: push: - branches: [ main, master ] + branches: [ main ] pull_request: - branches: [ main, master ] + branches: [ main ] workflow_dispatch: env: @@ -27,49 +27,58 @@ env: RUST_VERSION: "1.89.0" jobs: - build-artifacts: - name: Build deb-bootupd Artifacts + build: runs-on: ubuntu-latest + env: + FORGEJO_URL: ${{ secrets.FORGEJO_URL || 'https://git.raines.xyz' }} + FORGEJO_HOST: ${{ secrets.FORGEJO_HOST || 'git.raines.xyz' }} container: - # Use complete Rust image with all components pre-installed - # This avoids the "whack-a-mole" of adding components one by one - image: rust:1.89 + image: 'rust:1.89' + options: | + --dns=8.8.8.8 + --dns=8.8.4.4 + --add-host=forgejo:host-gateway steps: - name: Setup build environment - shell: bash run: | + # Update package lists apt update -y - apt install -y git curl pkg-config build-essential gnupg - # Rust 1.89.0 is already installed in rust:1.89-debian-trixie-slim - # No need for rustup or toolchain management! - echo "✅ Using pre-installed Rust from official image:" - rustc --version - cargo --version - - # Verify Rust version meets requirements (need 1.84.1+) - RUST_VERSION=$(rustc --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -1) - echo "Rust version: $RUST_VERSION" - - if [ "$(printf '%s\n' "1.84.1" "$RUST_VERSION" | sort -V | head -n1)" != "1.84.1" ]; then - echo "❌ Rust version $RUST_VERSION is too old, need 1.84.1+" - exit 1 - else - echo "✅ Rust version $RUST_VERSION meets requirement (1.84.1+)" - fi - - # Install additional build dependencies - apt install -y libssl-dev libsystemd-dev file pkg-config build-essential zip nodejs npm + # Install required system packages + apt install -y libssl-dev libsystemd-dev file pkg-config build-essential zip nodejs npm # Install required Rust components echo "Installing Rust components..." rustup component add clippy rustup component add rustfmt - rustup component add rust-src # For better error messages - rustup component add rust-analysis # For IDE support + rustup component add rust-src + rustup component add rust-analysis - echo "Available Rust components:" - rustup component list --installed + # Verify Rust installation + rustc --version + cargo --version + rustup component list | grep -E "(clippy|rustfmt|rust-src|rust-analysis)" + + # Test DNS resolution + echo "Testing DNS resolution..." + echo "Testing forgejo hostname resolution:" + nslookup forgejo || echo "forgejo hostname not resolved" + + echo "Testing explicit Forgejo host resolution:" + nslookup $FORGEJO_HOST || echo "Explicit hostname not resolved" + + echo "Testing external DNS:" + nslookup google.com || echo "External DNS not working" + + echo "Testing IP connectivity:" + ping -c 3 8.8.8.8 || echo "IP connectivity failed" + + # Show network configuration + echo "Network configuration:" + cat /etc/resolv.conf + ip route show + echo "Container hostname: $(hostname)" + echo "Container IP: $(hostname -i)" - name: Checkout repository manually run: | diff --git a/.forgejo/workflows/simple-build.yml b/.forgejo/workflows/simple-build.yml index 73c16c4..a1c08cf 100644 --- a/.forgejo/workflows/simple-build.yml +++ b/.forgejo/workflows/simple-build.yml @@ -1,27 +1,32 @@ -name: Simple Build & Upload +name: Simple Build and Upload # Simple workflow for building deb-bootupd and uploading artifacts # Based on patterns from: https://domaindrivenarchitecture.org/pages/dda-pallet/ on: push: - branches: [ main, master ] + branches: [ main ] pull_request: - branches: [ main, master ] + branches: [ main ] workflow_dispatch: jobs: build: runs-on: ubuntu-latest + env: + FORGEJO_URL: ${{ secrets.FORGEJO_URL || 'https://git.raines.xyz' }} + FORGEJO_HOST: ${{ secrets.FORGEJO_HOST || 'git.raines.xyz' }} container: - # Use complete Rust image with all components pre-installed - # This avoids the "whack-a-mole" of adding components one by one - image: rust:slim-trixie + image: 'rust:1.89-slim-trixie' + options: | + --dns=8.8.8.8 + --dns=8.8.4.4 + --add-host=forgejo:host-gateway steps: - name: Checkout code and setup environment run: | apt update -y - apt install -y git curl pkg-config libssl-dev libsystemd-dev build-essential file zip nodejs npm + apt install -y git curl pkg-config libssl-dev libsystemd-dev build-essential file zip nodejs npm # Install required Rust components echo "Installing Rust components..." @@ -30,6 +35,27 @@ jobs: rustup component add rust-src # For better error messages rustup component add rust-analysis # For IDE support + # Test DNS resolution + echo "Testing DNS resolution..." + echo "Testing forgejo hostname resolution:" + nslookup forgejo || echo "forgejo hostname not resolved" + + echo "Testing explicit Forgejo host resolution:" + nslookup $FORGEJO_HOST || echo "Explicit hostname not resolved" + + echo "Testing external DNS:" + nslookup google.com || echo "External DNS not working" + + echo "Testing IP connectivity:" + ping -c 3 8.8.8.8 || echo "IP connectivity failed" + + # Show network configuration + echo "Network configuration:" + cat /etc/resolv.conf + ip route show + echo "Container hostname: $(hostname)" + echo "Container IP: $(hostname -i)" + echo "Available Rust components:" rustup component list --installed echo "✅ Using pre-installed Rust from official image:"