Fix container networking: add DNS configuration and hostname resolution

This commit is contained in:
robojerk 2025-08-10 01:17:20 -07:00
parent 2b9f885009
commit 7119209882
2 changed files with 74 additions and 39 deletions

View file

@ -17,9 +17,9 @@ name: Build deb-bootupd Artifacts
on: on:
push: push:
branches: [ main, master ] branches: [ main ]
pull_request: pull_request:
branches: [ main, master ] branches: [ main ]
workflow_dispatch: workflow_dispatch:
env: env:
@ -27,49 +27,58 @@ env:
RUST_VERSION: "1.89.0" RUST_VERSION: "1.89.0"
jobs: jobs:
build-artifacts: build:
name: Build deb-bootupd Artifacts
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
FORGEJO_URL: ${{ secrets.FORGEJO_URL || 'https://git.raines.xyz' }}
FORGEJO_HOST: ${{ secrets.FORGEJO_HOST || 'git.raines.xyz' }}
container: container:
# Use complete Rust image with all components pre-installed image: 'rust:1.89'
# This avoids the "whack-a-mole" of adding components one by one options: |
image: rust:1.89 --dns=8.8.8.8
--dns=8.8.4.4
--add-host=forgejo:host-gateway
steps: steps:
- name: Setup build environment - name: Setup build environment
shell: bash
run: | run: |
# Update package lists
apt update -y 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 # Install required system packages
# No need for rustup or toolchain management! apt install -y libssl-dev libsystemd-dev file pkg-config build-essential zip nodejs npm
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 Rust components # Install required Rust components
echo "Installing Rust components..." echo "Installing Rust components..."
rustup component add clippy rustup component add clippy
rustup component add rustfmt rustup component add rustfmt
rustup component add rust-src # For better error messages rustup component add rust-src
rustup component add rust-analysis # For IDE support rustup component add rust-analysis
echo "Available Rust components:" # Verify Rust installation
rustup component list --installed 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 - name: Checkout repository manually
run: | run: |

View file

@ -1,27 +1,32 @@
name: Simple Build & Upload name: Simple Build and Upload
# Simple workflow for building deb-bootupd and uploading artifacts # Simple workflow for building deb-bootupd and uploading artifacts
# Based on patterns from: https://domaindrivenarchitecture.org/pages/dda-pallet/ # Based on patterns from: https://domaindrivenarchitecture.org/pages/dda-pallet/
on: on:
push: push:
branches: [ main, master ] branches: [ main ]
pull_request: pull_request:
branches: [ main, master ] branches: [ main ]
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
FORGEJO_URL: ${{ secrets.FORGEJO_URL || 'https://git.raines.xyz' }}
FORGEJO_HOST: ${{ secrets.FORGEJO_HOST || 'git.raines.xyz' }}
container: container:
# Use complete Rust image with all components pre-installed image: 'rust:1.89-slim-trixie'
# This avoids the "whack-a-mole" of adding components one by one options: |
image: rust:slim-trixie --dns=8.8.8.8
--dns=8.8.4.4
--add-host=forgejo:host-gateway
steps: steps:
- name: Checkout code and setup environment - name: Checkout code and setup environment
run: | run: |
apt update -y 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 # Install required Rust components
echo "Installing Rust components..." echo "Installing Rust components..."
@ -30,6 +35,27 @@ jobs:
rustup component add rust-src # For better error messages rustup component add rust-src # For better error messages
rustup component add rust-analysis # For IDE support 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:" echo "Available Rust components:"
rustup component list --installed rustup component list --installed
echo "✅ Using pre-installed Rust from official image:" echo "✅ Using pre-installed Rust from official image:"