Skip to content

Commit b053221

Browse files
lpcoxCopilot
andcommitted
fix: retry apt-get update on transient mirror failures in Dockerfiles
The initial apt-get update can fail with hash mismatches when Ubuntu mirrors are mid-sync. The existing retry logic only covered apt-get install failures, not apt-get update failures. This adds a retry with cache clear for the initial apt-get update in both agent and squid Dockerfiles. Fixes: squid-proxy build failure (exit code 100) in --build-local CI Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dd2d1c7 commit b053221

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

containers/agent/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ FROM ${BASE_IMAGE}
1111

1212
# Install required packages and Node.js 22
1313
# Note: Some packages may already exist in runner-like base images, apt handles this gracefully
14-
# Retry logic handles transient 404s when Ubuntu archive supersedes package versions mid-build
14+
# Retry logic handles transient mirror hash-mismatches and 404s during apt-get update/install
1515
RUN set -eux; \
1616
PKGS="iptables curl ca-certificates git gh gnupg dnsutils net-tools netcat-openbsd gosu libcap2-bin"; \
17-
apt-get update && \
17+
( apt-get update || (sleep 5 && rm -rf /var/lib/apt/lists/* && apt-get update) ) && \
1818
( apt-get install -y --no-install-recommends $PKGS || \
1919
(echo "apt-get install failed, retrying with fresh package index..." && \
2020
rm -rf /var/lib/apt/lists/* && \
@@ -40,7 +40,7 @@ RUN set -eux; \
4040
# See: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
4141
RUN set -eux; \
4242
PARITY_PKGS="libgdiplus libev-dev libssl-dev php-intl php-gd"; \
43-
apt-get update && \
43+
( apt-get update || (sleep 5 && rm -rf /var/lib/apt/lists/* && apt-get update) ) && \
4444
( apt-get install -y --no-install-recommends $PARITY_PKGS || \
4545
(echo "apt-get install failed, retrying with fresh package index..." && \
4646
rm -rf /var/lib/apt/lists/* && \
@@ -51,7 +51,8 @@ RUN set -eux; \
5151
# Upgrade all packages to pick up security patches
5252
# Addresses CVE-2023-44487 (HTTP/2 Rapid Reset) and other known vulnerabilities
5353
# Retry logic handles transient mirror sync failures during apt-get update
54-
RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/* || \
54+
RUN ( apt-get update || (sleep 5 && rm -rf /var/lib/apt/lists/* && apt-get update) ) && \
55+
apt-get upgrade -y && rm -rf /var/lib/apt/lists/* || \
5556
(echo "apt-get upgrade failed, retrying with fresh package index..." && \
5657
rm -rf /var/lib/apt/lists/* && \
5758
apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/*)

containers/squid/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
FROM ubuntu/squid:latest
22

33
# Install additional tools for debugging, healthcheck, and SSL Bump
4-
# Retry logic handles transient 404s when Ubuntu archive supersedes package versions mid-build
4+
# Retry logic handles transient mirror hash-mismatches and 404s during apt-get update/install
55
RUN set -eux; \
66
PKGS="curl dnsutils net-tools netcat-openbsd openssl squid-openssl"; \
7-
apt-get update && \
7+
( apt-get update || (sleep 5 && rm -rf /var/lib/apt/lists/* && apt-get update) ) && \
88
apt-get install -y --only-upgrade gpgv && \
99
( apt-get install -y --no-install-recommends $PKGS || \
1010
(rm -rf /var/lib/apt/lists/* && apt-get update && \

0 commit comments

Comments
 (0)