Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .docker/apt-mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
# Reconfigure Ubuntu apt sources to point at an alternate mirror.
#
# Used by Dockerfiles via `RUN --mount=type=bind,source=.docker/apt-mirror.sh,...`
# and by CI workflows on the runner to mitigate outages of the default
# archive.ubuntu.com / security.ubuntu.com / ports.ubuntu.com pool.
#
# Inputs (env):
# APT_MIRROR Replacement for archive.ubuntu.com and security.ubuntu.com
# (e.g. "http://azure.archive.ubuntu.com" or
# "https://mirrors.edge.kernel.org").
# Leave empty to keep upstream. The trailing "/ubuntu/..."
# path is preserved by the rewrite.
# APT_PORTS_MIRROR Replacement for ports.ubuntu.com (arm64/ppc64el/...).
# Leave empty to keep upstream.
#
# Both default to empty, in which case the script is a no-op.

set -e

if [ -z "${APT_MIRROR}" ] && [ -z "${APT_PORTS_MIRROR}" ]; then
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. We rewrite whichever exists.
for f in /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list; do
[ -f "$f" ] || continue
if [ -n "${APT_MIRROR}" ]; then
# Use a comma delimiter so the alternation pipe in the regex
# is not interpreted as the s/// separator.
sed -i -E "s,https?://(archive\.ubuntu\.com|security\.ubuntu\.com),${APT_MIRROR},g" "$f"
fi
if [ -n "${APT_PORTS_MIRROR}" ]; then
sed -i -E "s,https?://ports\.ubuntu\.com,${APT_PORTS_MIRROR},g" "$f"
fi
done

echo "apt-mirror: rewrote sources (APT_MIRROR='${APT_MIRROR}', APT_PORTS_MIRROR='${APT_PORTS_MIRROR}')"
49 changes: 49 additions & 0 deletions .github/actions/configure-apt-mirror/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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.

Pass mirror: '' (empty string) to skip the rewrite and keep upstream.

inputs:
mirror:
description: 'Replacement URL for archive.ubuntu.com / security.ubuntu.com (empty = keep upstream)'
required: false
default: 'http://azure.archive.ubuntu.com'
ports-mirror:
description: 'Replacement URL for ports.ubuntu.com on arm64 (empty = keep upstream)'
required: false
default: 'http://azure.ports.ubuntu.com'

runs:
using: 'composite'
steps:
- name: Rewrite apt sources
shell: bash
env:
APT_MIRROR: ${{ inputs.mirror }}
APT_PORTS_MIRROR: ${{ inputs.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.
for f in /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list; do
sudo test -f "$f" || continue
if [ -n "${APT_MIRROR}" ]; then
# Comma delimiter so the alternation pipe in the regex is not
# interpreted as the s/// separator.
sudo sed -i -E "s,https?://(archive\.ubuntu\.com|security\.ubuntu\.com),${APT_MIRROR},g" "$f"
fi
if [ -n "${APT_PORTS_MIRROR}" ]; then
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}'"
38 changes: 24 additions & 14 deletions .github/workflows/backend_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ 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
Expand All @@ -80,6 +90,16 @@ jobs:
quay_username: ${{ secrets.quayUsername }}
steps:

- name: Checkout
uses: actions/checkout@v6
with:
submodules: true

- name: Configure apt mirror on runner
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'
Expand All @@ -97,20 +117,6 @@ jobs:
docker-images: true
swap-storage: true

- name: Force Install GIT latest
run: |
sudo apt-get update \
&& sudo apt-get install -y software-properties-common \
&& sudo apt-get update \
&& sudo add-apt-repository -y ppa:git-core/ppa \
&& sudo apt-get update \
&& sudo apt-get install -y git

- name: Checkout
uses: actions/checkout@v6
with:
submodules: true

- name: Release space from worker
if: inputs.runs-on == 'ubuntu-latest'
run: |
Expand Down Expand Up @@ -231,6 +237,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 }}
DEPS_REFRESH=${{ steps.deps_refresh.outputs.key }}
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
Expand All @@ -255,6 +263,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 }}
DEPS_REFRESH=${{ steps.deps_refresh.outputs.key }}
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Configure apt mirror on runner
uses: ./.github/actions/configure-apt-mirror
- name: Set up Go
uses: actions/setup-go@v5
with:
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/checksum_checker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@ jobs:
if: github.repository == 'mudler/LocalAI'
runs-on: ubuntu-latest
steps:
- name: Force Install GIT latest
run: |
sudo apt-get update \
&& sudo apt-get install -y software-properties-common \
&& sudo apt-get update \
&& sudo add-apt-repository -y ppa:git-core/ppa \
&& sudo apt-get update \
&& sudo apt-get install -y git
- uses: actions/checkout@v6
- name: Configure apt mirror on runner
uses: ./.github/actions/configure-apt-mirror
- name: Install dependencies
run: |
sudo apt-get update
Expand Down
33 changes: 23 additions & 10 deletions .github/workflows/image_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ 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
Expand All @@ -70,6 +80,15 @@ jobs:
runs-on: ${{ inputs.runs-on }}
steps:

- name: Checkout
uses: actions/checkout@v6

- name: Configure apt mirror on runner
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'
uses: jlumbroso/free-disk-space@main
Expand All @@ -85,16 +104,6 @@ jobs:
large-packages: true
docker-images: true
swap-storage: true
- name: Force Install GIT latest
run: |
sudo apt-get update \
&& sudo apt-get install -y software-properties-common \
&& sudo apt-get update \
&& sudo add-apt-repository -y ppa:git-core/ppa \
&& sudo apt-get update \
&& sudo apt-get install -y git
- name: Checkout
uses: actions/checkout@v6

- name: Release space from worker
if: inputs.runs-on == 'ubuntu-latest'
Expand Down Expand Up @@ -205,6 +214,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 }}
context: .
file: ./Dockerfile
cache-from: type=registry,ref=quay.io/go-skynet/ci-cache:cache-localai${{ inputs.tag-suffix }}
Expand All @@ -228,6 +239,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 }}
context: .
file: ./Dockerfile
cache-from: type=registry,ref=quay.io/go-skynet/ci-cache:cache-localai${{ inputs.tag-suffix }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Configure apt mirror on runner
uses: ./.github/actions/configure-apt-mirror
- name: Set up Go
uses: actions/setup-go@v5
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
uses: actions/checkout@v6
with:
submodules: true
- name: Configure apt mirror on runner
uses: ./.github/actions/configure-apt-mirror
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests-ui-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
uses: actions/checkout@v6
with:
submodules: true
- name: Configure apt mirror on runner
uses: ./.github/actions/configure-apt-mirror
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/update_swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Configure apt mirror on runner
uses: ./.github/actions/configure-apt-mirror
- uses: actions/setup-go@v5
with:
go-version: 'stable'
Expand Down
16 changes: 14 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
ARG BASE_IMAGE=ubuntu:24.04
ARG INTEL_BASE_IMAGE=${BASE_IMAGE}
ARG UBUNTU_CODENAME=noble
# Optional alternate Ubuntu apt mirror(s). Empty = use upstream.
# See .docker/apt-mirror.sh for accepted values.
ARG APT_MIRROR=""
ARG APT_PORTS_MIRROR=""

FROM ${BASE_IMAGE} AS requirements

ARG APT_MIRROR
ARG APT_PORTS_MIRROR
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
RUN --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
APT_MIRROR="${APT_MIRROR}" APT_PORTS_MIRROR="${APT_PORTS_MIRROR}" sh /usr/local/sbin/apt-mirror && \
apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates curl wget espeak-ng libgomp1 \
ffmpeg libopenblas0 libopenblas-dev libopus0 sox && \
Expand Down Expand Up @@ -240,10 +248,14 @@ WORKDIR /build
# This is a temporary workaround until Intel fixes their repository
FROM ${INTEL_BASE_IMAGE} AS intel
ARG UBUNTU_CODENAME=noble
ARG APT_MIRROR
ARG APT_PORTS_MIRROR
RUN wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | \
gpg --yes --dearmor --output /usr/share/keyrings/intel-graphics.gpg
RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu ${UBUNTU_CODENAME}/lts/2350 unified" > /etc/apt/sources.list.d/intel-graphics.list
RUN apt-get update && \
RUN --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
APT_MIRROR="${APT_MIRROR}" APT_PORTS_MIRROR="${APT_PORTS_MIRROR}" sh /usr/local/sbin/apt-mirror && \
apt-get update && \
apt-get install -y --no-install-recommends \
intel-oneapi-runtime-libs && \
apt-get clean && \
Expand Down
Loading
Loading