Skip to content

Commit ad238e7

Browse files
richiejplocalai-org-maint-bot
authored andcommitted
fix(ci): preserve system CA trust
Build a combined runner certificate bundle instead of replacing public roots with the generated proxy CA. Centralize additive container installation in the shared proxy CA helper. Assisted-by: Codex:gpt-5 Signed-off-by: Richard Palethorpe <io@richiejp.com>
1 parent cc651fd commit ad238e7

16 files changed

Lines changed: 54 additions & 46 deletions

.docker/apt-mirror.sh

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,8 @@
1717

1818
set -e
1919

20-
# BuildKit exposes the ephemeral interception CA at this dedicated path. Copy
21-
# it into the image trust bundle only when the proxy-enabled workflows supply
22-
# it; ordinary local and test builds retain their base-image trust unchanged.
23-
proxy_ca=/run/secrets/build_proxy_ca
24-
if [ -s "$proxy_ca" ]; then
25-
# Keep the generated CA in the distribution-managed local certificate
26-
# directory. Installing or upgrading ca-certificates later in this layer
27-
# regenerates the bundle, so appending directly to it would be lost.
28-
mkdir -p /usr/local/share/ca-certificates
29-
cp "$proxy_ca" /usr/local/share/ca-certificates/localai-build-proxy.crt
30-
if command -v update-ca-certificates >/dev/null 2>&1; then
31-
update-ca-certificates
32-
fi
33-
cat > /etc/apt/apt.conf.d/99localai-build-proxy-ca <<EOF
34-
Acquire::https::CaInfo "$proxy_ca";
35-
EOF
20+
if [ -f /usr/local/sbin/install-build-proxy-ca ]; then
21+
sh /usr/local/sbin/install-build-proxy-ca
3622
fi
3723

3824
# Ubuntu 24.04 (noble) ships DEB822 sources at /etc/apt/sources.list.d/ubuntu.sources;

.docker/install-base-deps.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,6 @@
3535

3636
set -eux
3737

38-
# Some callers use this script without apt-mirror.sh. Ensure those first-stage
39-
# downloads also trust the proxy without masking the normal system CA bundle.
40-
proxy_ca=/run/secrets/build_proxy_ca
41-
if [ -s "$proxy_ca" ]; then
42-
# Persist the generated CA as a local certificate so a subsequent
43-
# ca-certificates package install cannot regenerate the bundle without it.
44-
mkdir -p /usr/local/share/ca-certificates
45-
cp "$proxy_ca" /usr/local/share/ca-certificates/localai-build-proxy.crt
46-
if command -v update-ca-certificates >/dev/null 2>&1; then
47-
update-ca-certificates
48-
fi
49-
cat > /etc/apt/apt.conf.d/99localai-build-proxy-ca <<EOF
50-
Acquire::https::CaInfo "$proxy_ca";
51-
EOF
52-
fi
53-
5438
# --- 0. apt mirror rewrite (no-op when APT_MIRROR / APT_PORTS_MIRROR unset) ---
5539
if [ -x /usr/local/sbin/apt-mirror ]; then
5640
APT_MIRROR="${APT_MIRROR:-}" APT_PORTS_MIRROR="${APT_PORTS_MIRROR:-}" \

.docker/install-build-proxy-ca.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,17 @@ fi
1010

1111
mkdir -p /usr/local/share/ca-certificates
1212
cp "$proxy_ca" /usr/local/share/ca-certificates/localai-build-proxy.crt
13-
update-ca-certificates
13+
if command -v update-ca-certificates >/dev/null 2>&1; then
14+
update-ca-certificates
15+
elif [ -f /etc/ssl/certs/ca-certificates.crt ]; then
16+
cat "$proxy_ca" >>/etc/ssl/certs/ca-certificates.crt
17+
else
18+
echo 'build proxy: no system CA bundle found' >&2
19+
exit 1
20+
fi
21+
22+
if [ -d /etc/apt/apt.conf.d ]; then
23+
cat > /etc/apt/apt.conf.d/99localai-build-proxy-ca <<EOF
24+
Acquire::https::CaInfo "$proxy_ca";
25+
EOF
26+
fi

.github/scripts/start-build-proxy.sh

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,38 @@ for _ in $(seq 1 50); do
1111
done
1212
grep '^proxy=' "$output/proxy.log"
1313
grep '^ca=' "$output/proxy.log"
14+
proxy_ca="$output/ca/ca.crt"
15+
ca_bundle="$output/ca/ca-bundle.crt"
16+
system_ca=""
17+
for candidate in \
18+
/etc/ssl/certs/ca-certificates.crt \
19+
/etc/ssl/cert.pem \
20+
/etc/pki/tls/certs/ca-bundle.crt \
21+
/etc/openssl/certs/ca-certificates.crt; do
22+
if test -s "$candidate"; then
23+
system_ca="$candidate"
24+
break
25+
fi
26+
done
27+
if test -z "$system_ca"; then
28+
echo 'build proxy: unable to find the runner system CA bundle' >&2
29+
exit 1
30+
fi
31+
cat "$system_ca" "$proxy_ca" >"$ca_bundle"
1432
{
1533
echo "LOCALAI_BUILD_PROXY=http://127.0.0.1:18080"
1634
echo "LOCALAI_BUILD_PROXY_OUTPUT=$output"
17-
echo "LOCALAI_BUILD_PROXY_CA=$output/ca/ca.crt"
35+
echo "LOCALAI_BUILD_PROXY_CA=$proxy_ca"
36+
echo "LOCALAI_BUILD_PROXY_CA_BUNDLE=$ca_bundle"
1837
echo "HTTP_PROXY=http://127.0.0.1:18080"
1938
echo "HTTPS_PROXY=http://127.0.0.1:18080"
2039
echo "http_proxy=http://127.0.0.1:18080"
2140
echo "https_proxy=http://127.0.0.1:18080"
22-
echo "SSL_CERT_FILE=$output/ca/ca.crt"
23-
echo "CURL_CA_BUNDLE=$output/ca/ca.crt"
24-
echo "REQUESTS_CA_BUNDLE=$output/ca/ca.crt"
25-
echo "GIT_SSL_CAINFO=$output/ca/ca.crt"
26-
echo "NODE_EXTRA_CA_CERTS=$output/ca/ca.crt"
41+
echo "SSL_CERT_FILE=$ca_bundle"
42+
echo "CURL_CA_BUNDLE=$ca_bundle"
43+
echo "REQUESTS_CA_BUNDLE=$ca_bundle"
44+
echo "GIT_SSL_CAINFO=$ca_bundle"
45+
echo "NODE_EXTRA_CA_CERTS=$proxy_ca"
2746
echo "NO_PROXY=localhost,127.0.0.1"
2847
echo "no_proxy=localhost,127.0.0.1"
2948
} >>"$GITHUB_ENV"

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ENV DEBIAN_FRONTEND=noninteractive
2323
# hwdata ships /usr/share/hwdata/pci.ids. Without it, the ghw library we use
2424
# for hardware detection cannot resolve PCI vendor IDs and fails to enumerate
2525
# GPUs at all, so the image reports "No GPU detected" (see issue #10941).
26-
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
26+
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/install-build-proxy-ca.sh,target=/usr/local/sbin/install-build-proxy-ca --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
2727
APT_MIRROR="${APT_MIRROR}" APT_PORTS_MIRROR="${APT_PORTS_MIRROR}" sh /usr/local/sbin/apt-mirror && \
2828
apt-get update && \
2929
apt-get install -y --no-install-recommends \
@@ -278,7 +278,7 @@ ARG APT_PORTS_MIRROR
278278
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | \
279279
gpg --yes --dearmor --output /usr/share/keyrings/intel-graphics.gpg
280280
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 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
281-
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
281+
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/install-build-proxy-ca.sh,target=/usr/local/sbin/install-build-proxy-ca --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
282282
APT_MIRROR="${APT_MIRROR}" APT_PORTS_MIRROR="${APT_PORTS_MIRROR}" sh /usr/local/sbin/apt-mirror && \
283283
apt-get update && \
284284
apt-get install -y --no-install-recommends \

backend/Dockerfile.audio-cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ WORKDIR /build
7777
#
7878
# BUILD_TYPE=vulkan additionally needs the loader headers and glslc; both are in
7979
# Noble. The CUDA toolkit for BUILD_TYPE=cublas comes from BASE_IMAGE.
80-
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
80+
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/install-build-proxy-ca.sh,target=/usr/local/sbin/install-build-proxy-ca --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
8181
sh /usr/local/sbin/apt-mirror && \
8282
apt-get update && \
8383
apt-get install -y --no-install-recommends \

backend/Dockerfile.base-grpc-builder

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ WORKDIR /build
9696
# script the variant Dockerfiles' builder-fromsource stage runs.
9797
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/install-base-deps.sh,target=/usr/local/sbin/install-base-deps \
9898
--mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
99+
--mount=type=bind,source=.docker/install-build-proxy-ca.sh,target=/usr/local/sbin/install-build-proxy-ca \
99100
bash /usr/local/sbin/install-base-deps
100101

101102
WORKDIR /

backend/Dockerfile.bonsai

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ WORKDIR /build
7878
# this from-source path are bit-equivalent.
7979
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/install-base-deps.sh,target=/usr/local/sbin/install-base-deps \
8080
--mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
81+
--mount=type=bind,source=.docker/install-build-proxy-ca.sh,target=/usr/local/sbin/install-build-proxy-ca \
8182
bash /usr/local/sbin/install-base-deps
8283

8384
# Mirror builder-prebuilt: copy gRPC from /opt/grpc to /usr/local so

backend/Dockerfile.ds4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ WORKDIR /build
2727
# - gRPC/Protobuf: system apt packages are sufficient; ds4's wrapper only links
2828
# against them, it doesn't ship the gRPC source tree.
2929
# - nlohmann-json: dsml_renderer's only third-party dep.
30-
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
30+
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/install-build-proxy-ca.sh,target=/usr/local/sbin/install-build-proxy-ca --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
3131
APT_MIRROR="${APT_MIRROR}" APT_PORTS_MIRROR="${APT_PORTS_MIRROR}" sh /usr/local/sbin/apt-mirror && \
3232
apt-get update && \
3333
apt-get install -y --no-install-recommends \

backend/Dockerfile.golang

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ARG APT_PORTS_MIRROR
3030
# build-essential. So: try gcc-14 from the configured repos, fall back
3131
# gracefully when it's not available so jammy-based builds don't fail
3232
# at the apt step.
33-
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
33+
RUN --mount=type=secret,id=build_proxy_ca,target=/run/secrets/build_proxy_ca,mode=0444 --mount=type=bind,source=.docker/install-build-proxy-ca.sh,target=/usr/local/sbin/install-build-proxy-ca --mount=type=bind,source=.docker/apt-mirror.sh,target=/usr/local/sbin/apt-mirror \
3434
APT_MIRROR="${APT_MIRROR}" APT_PORTS_MIRROR="${APT_PORTS_MIRROR}" sh /usr/local/sbin/apt-mirror && \
3535
apt-get update && \
3636
apt-get install -y --no-install-recommends \

0 commit comments

Comments
 (0)