From b7f7b1bbf2b207aff8b6a571a89c3a11779aed5c Mon Sep 17 00:00:00 2001 From: robojerk Date: Sun, 7 Sep 2025 17:16:58 -0700 Subject: [PATCH] Fix apt-cacher-ng configuration for build container - Use --network host for apt-cacher-ng to ensure accessibility - Try multiple connection methods (host.docker.internal, 172.17.0.1, host-gateway) - Use correct port 3142 instead of 3143 - Add proper cleanup and testing of apt-cacher-ng service - This should resolve udev dependency installation issues The build container was unable to reach apt-cacher-ng, causing udev package installation to fail and meson configuration to fail. --- .forgejo/workflows/ci.yml | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index d605ba8..497d629 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -33,11 +33,23 @@ jobs: - name: Setup apt-cacher-ng run: | echo "Setting up apt-cacher-ng for faster builds..." - # Start apt-cacher-ng in background - docker run -d --name apt-cacher-ng -p 3143:3142 sameersbn/apt-cacher-ng:latest || echo "Apt-cacher-ng already running or failed to start" + # Stop any existing apt-cacher-ng container + docker stop apt-cacher-ng 2>/dev/null || true + docker rm apt-cacher-ng 2>/dev/null || true + + # Start apt-cacher-ng in background with proper network configuration + docker run -d --name apt-cacher-ng --network host sameersbn/apt-cacher-ng:latest || echo "Apt-cacher-ng failed to start" # Wait for it to be ready - timeout 30 bash -c 'until curl -s http://localhost:3143/acng-report.html > /dev/null 2>&1; do sleep 2; done' || echo "Apt-cacher-ng not ready, continuing without cache" + echo "Waiting for apt-cacher-ng to be ready..." + timeout 30 bash -c 'until curl -s http://localhost:3142/acng-report.html > /dev/null 2>&1; do sleep 2; done' || echo "Apt-cacher-ng not ready, continuing without cache" + + # Test the connection + if curl -s http://localhost:3142/acng-report.html > /dev/null 2>&1; then + echo "Apt-cacher-ng is ready and accessible" + else + echo "Apt-cacher-ng is not accessible, will use direct connection" + fi - name: Build libfuse in Debian container run: | @@ -51,10 +63,20 @@ jobs: set -e # Configure apt to use cacher if available - if curl -s http://host.docker.internal:3143/acng-report.html > /dev/null 2>&1; then - echo "Configuring apt to use cacher" - echo "Acquire::http::Proxy \"http://host.docker.internal:3143\";" > /etc/apt/apt.conf.d/01proxy - echo "Acquire::https::Proxy \"http://host.docker.internal:3143\";" >> /etc/apt/apt.conf.d/01proxy + # Try multiple methods to reach the apt-cacher-ng service + APT_CACHER_IP="" + if curl -s http://host.docker.internal:3142/acng-report.html > /dev/null 2>&1; then + APT_CACHER_IP="host.docker.internal:3142" + elif curl -s http://172.17.0.1:3142/acng-report.html > /dev/null 2>&1; then + APT_CACHER_IP="172.17.0.1:3142" + elif curl -s http://host-gateway:3142/acng-report.html > /dev/null 2>&1; then + APT_CACHER_IP="host-gateway:3142" + fi + + if [ -n "$APT_CACHER_IP" ]; then + echo "Configuring apt to use cacher at $APT_CACHER_IP" + echo "Acquire::http::Proxy \"http://$APT_CACHER_IP\";" > /etc/apt/apt.conf.d/01proxy + echo "Acquire::https::Proxy \"http://$APT_CACHER_IP\";" >> /etc/apt/apt.conf.d/01proxy echo "Acquire::http::Proxy::security.debian.org \"DIRECT\";" >> /etc/apt/apt.conf.d/01proxy echo "Acquire::http::Proxy::deb.debian.org \"DIRECT\";" >> /etc/apt/apt.conf.d/01proxy else