fix(ci): switch apt mirror per runner — azure on github-hosted, kernel.org on self-hosted

Self-hosted runners (arc-runner-set, bigger-runner) cannot reach
azure.archive.ubuntu.com — they live in different networks (e.g. our
arc-runner-set Kubernetes cluster) where Azure's mirror IP is not
routable. Symptom: "Connection failed [IP: 51.11.236.225 80]" with each
Ign:/Err: cycle taking 60s, hanging the build for ~16 minutes before
exit 100.

Pick the mirror based on `runner.environment`:

  * github-hosted (ubuntu-latest, ubuntu-24.04-arm) → Azure
    (http://azure.archive.ubuntu.com / http://azure.ports.ubuntu.com)
    — same VPC as the runner.
  * self-hosted (arc-runner-set, bigger-runner)    → kernel.org
    (https://mirrors.edge.kernel.org for both archive and ports)
    — publicly reachable from any network.

The choice now lives in one place: the .github/actions/configure-apt-mirror
composite action exposes `effective-mirror` / `effective-ports-mirror`
outputs so the reusable workflows can forward the same value as Docker
build-args without duplicating the per-runner-environment branch.

The now-redundant `apt-mirror` / `apt-ports-mirror` workflow inputs on
image_build.yml and backend_build.yml are dropped — defaults live in the
composite action and are visible there.

Assisted-by: Claude:claude-opus-4-7[1m] [Claude Code]
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2026-05-03 22:54:51 +00:00
parent 8edac61e57
commit 50580a84ae
3 changed files with 69 additions and 51 deletions

View File

@@ -1,37 +1,79 @@
name: 'Configure apt mirror'
description: |
Reconfigure the GitHub Actions runner's Ubuntu apt sources to use an
alternate mirror. Defaults to the Azure-hosted Ubuntu mirror, which lives
on the same network as the runners and is independent of the canonical
Ubuntu pool — useful as a fallback when archive.ubuntu.com /
security.ubuntu.com / ports.ubuntu.com are degraded.
alternate mirror, and emit the effective URLs as outputs so callers can
forward them as Docker build-args.
Pass mirror: '' (empty string) to skip the rewrite and keep upstream.
Two mirror profiles depending on where the runner lives, because the
best mirror differs by network:
* github-hosted runners run on Azure, so they default to the
Azure-hosted Ubuntu mirror (lowest latency, same VPC).
* self-hosted runners (arc-runner-set, bigger-runner, ...) typically
cannot route to azure.archive.ubuntu.com, so they default to the
kernel.org mirror, which is publicly reachable from anywhere.
Pass an empty string to either input to skip the rewrite for that
profile and keep upstream archive.ubuntu.com / ports.ubuntu.com.
inputs:
mirror:
description: 'Replacement URL for archive.ubuntu.com / security.ubuntu.com (empty = keep upstream)'
github-hosted-mirror:
description: 'archive/security mirror URL for github-hosted runners (empty = upstream)'
required: false
default: 'http://azure.archive.ubuntu.com'
ports-mirror:
description: 'Replacement URL for ports.ubuntu.com on arm64 (empty = keep upstream)'
github-hosted-ports-mirror:
description: 'ports.ubuntu.com mirror URL for github-hosted runners (empty = upstream)'
required: false
default: 'http://azure.ports.ubuntu.com'
self-hosted-mirror:
description: 'archive/security mirror URL for self-hosted runners (empty = upstream)'
required: false
default: 'https://mirrors.edge.kernel.org'
self-hosted-ports-mirror:
description: 'ports.ubuntu.com mirror URL for self-hosted runners (empty = upstream)'
required: false
default: 'https://mirrors.edge.kernel.org'
outputs:
effective-mirror:
description: 'The mirror URL actually applied for this runner (or empty)'
value: ${{ steps.pick.outputs.mirror }}
effective-ports-mirror:
description: 'The ports mirror URL actually applied for this runner (or empty)'
value: ${{ steps.pick.outputs.ports-mirror }}
runs:
using: 'composite'
steps:
- name: Rewrite apt sources
- name: Pick effective mirror for this runner
id: pick
shell: bash
env:
APT_MIRROR: ${{ inputs.mirror }}
APT_PORTS_MIRROR: ${{ inputs.ports-mirror }}
RUNNER_ENV: ${{ runner.environment }}
GH_MIRROR: ${{ inputs.github-hosted-mirror }}
GH_PORTS_MIRROR: ${{ inputs.github-hosted-ports-mirror }}
SH_MIRROR: ${{ inputs.self-hosted-mirror }}
SH_PORTS_MIRROR: ${{ inputs.self-hosted-ports-mirror }}
run: |
if [ "${RUNNER_ENV}" = "github-hosted" ]; then
MIRROR="${GH_MIRROR}"
PORTS_MIRROR="${GH_PORTS_MIRROR}"
else
MIRROR="${SH_MIRROR}"
PORTS_MIRROR="${SH_PORTS_MIRROR}"
fi
echo "configure-apt-mirror: runner=${RUNNER_ENV} mirror='${MIRROR}' ports-mirror='${PORTS_MIRROR}'"
echo "mirror=${MIRROR}" >> "$GITHUB_OUTPUT"
echo "ports-mirror=${PORTS_MIRROR}" >> "$GITHUB_OUTPUT"
- name: Rewrite apt sources
if: steps.pick.outputs.mirror != '' || steps.pick.outputs.ports-mirror != ''
shell: bash
env:
APT_MIRROR: ${{ steps.pick.outputs.mirror }}
APT_PORTS_MIRROR: ${{ steps.pick.outputs.ports-mirror }}
run: |
set -e
if [ -z "${APT_MIRROR}" ] && [ -z "${APT_PORTS_MIRROR}" ]; then
echo "configure-apt-mirror: both inputs empty, leaving upstream sources untouched"
exit 0
fi
# Ubuntu 24.04 (noble) ships DEB822 sources at
# /etc/apt/sources.list.d/ubuntu.sources; older releases use
# /etc/apt/sources.list. Rewrite whichever exists.
@@ -46,4 +88,4 @@ runs:
sudo sed -i -E "s,https?://ports\.ubuntu\.com,${APT_PORTS_MIRROR},g" "$f"
fi
done
echo "configure-apt-mirror: APT_MIRROR='${APT_MIRROR}' APT_PORTS_MIRROR='${APT_PORTS_MIRROR}'"
echo "Runner apt mirror configured (APT_MIRROR='${APT_MIRROR}', APT_PORTS_MIRROR='${APT_PORTS_MIRROR}')"

View File

@@ -63,16 +63,6 @@ on:
required: false
default: ''
type: string
apt-mirror:
description: 'Replacement URL for archive.ubuntu.com / security.ubuntu.com (empty = use upstream)'
required: false
default: 'http://azure.archive.ubuntu.com'
type: string
apt-ports-mirror:
description: 'Replacement URL for ports.ubuntu.com (arm64 etc., empty = use upstream)'
required: false
default: 'http://azure.ports.ubuntu.com'
type: string
secrets:
dockerUsername:
required: false
@@ -96,10 +86,8 @@ jobs:
submodules: true
- name: Configure apt mirror on runner
id: apt_mirror
uses: ./.github/actions/configure-apt-mirror
with:
mirror: ${{ inputs.apt-mirror }}
ports-mirror: ${{ inputs.apt-ports-mirror }}
- name: Free Disk Space (Ubuntu)
if: inputs.runs-on == 'ubuntu-latest'
@@ -237,8 +225,8 @@ jobs:
BACKEND=${{ inputs.backend }}
UBUNTU_VERSION=${{ inputs.ubuntu-version }}
AMDGPU_TARGETS=${{ inputs.amdgpu-targets }}
APT_MIRROR=${{ inputs.apt-mirror }}
APT_PORTS_MIRROR=${{ inputs.apt-ports-mirror }}
APT_MIRROR=${{ steps.apt_mirror.outputs.effective-mirror }}
APT_PORTS_MIRROR=${{ steps.apt_mirror.outputs.effective-ports-mirror }}
DEPS_REFRESH=${{ steps.deps_refresh.outputs.key }}
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
@@ -263,8 +251,8 @@ jobs:
BACKEND=${{ inputs.backend }}
UBUNTU_VERSION=${{ inputs.ubuntu-version }}
AMDGPU_TARGETS=${{ inputs.amdgpu-targets }}
APT_MIRROR=${{ inputs.apt-mirror }}
APT_PORTS_MIRROR=${{ inputs.apt-ports-mirror }}
APT_MIRROR=${{ steps.apt_mirror.outputs.effective-mirror }}
APT_PORTS_MIRROR=${{ steps.apt_mirror.outputs.effective-ports-mirror }}
DEPS_REFRESH=${{ steps.deps_refresh.outputs.key }}
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}

View File

@@ -56,16 +56,6 @@ on:
required: false
default: 'noble'
type: string
apt-mirror:
description: 'Replacement URL for archive.ubuntu.com / security.ubuntu.com (empty = use upstream)'
required: false
default: 'http://azure.archive.ubuntu.com'
type: string
apt-ports-mirror:
description: 'Replacement URL for ports.ubuntu.com (arm64 etc., empty = use upstream)'
required: false
default: 'http://azure.ports.ubuntu.com'
type: string
secrets:
dockerUsername:
required: true
@@ -84,10 +74,8 @@ jobs:
uses: actions/checkout@v6
- name: Configure apt mirror on runner
id: apt_mirror
uses: ./.github/actions/configure-apt-mirror
with:
mirror: ${{ inputs.apt-mirror }}
ports-mirror: ${{ inputs.apt-ports-mirror }}
- name: Free Disk Space (Ubuntu)
if: inputs.runs-on == 'ubuntu-latest'
@@ -214,8 +202,8 @@ jobs:
SKIP_DRIVERS=${{ inputs.skip-drivers }}
UBUNTU_VERSION=${{ inputs.ubuntu-version }}
UBUNTU_CODENAME=${{ inputs.ubuntu-codename }}
APT_MIRROR=${{ inputs.apt-mirror }}
APT_PORTS_MIRROR=${{ inputs.apt-ports-mirror }}
APT_MIRROR=${{ steps.apt_mirror.outputs.effective-mirror }}
APT_PORTS_MIRROR=${{ steps.apt_mirror.outputs.effective-ports-mirror }}
context: .
file: ./Dockerfile
cache-from: type=registry,ref=quay.io/go-skynet/ci-cache:cache-localai${{ inputs.tag-suffix }}
@@ -239,8 +227,8 @@ jobs:
SKIP_DRIVERS=${{ inputs.skip-drivers }}
UBUNTU_VERSION=${{ inputs.ubuntu-version }}
UBUNTU_CODENAME=${{ inputs.ubuntu-codename }}
APT_MIRROR=${{ inputs.apt-mirror }}
APT_PORTS_MIRROR=${{ inputs.apt-ports-mirror }}
APT_MIRROR=${{ steps.apt_mirror.outputs.effective-mirror }}
APT_PORTS_MIRROR=${{ steps.apt_mirror.outputs.effective-ports-mirror }}
context: .
file: ./Dockerfile
cache-from: type=registry,ref=quay.io/go-skynet/ci-cache:cache-localai${{ inputs.tag-suffix }}