From 6e835c83eb92f58b21c5588334c1d049c52f8de1 Mon Sep 17 00:00:00 2001 From: zwitschi Date: Fri, 14 Nov 2025 14:12:02 +0100 Subject: [PATCH] fix(Dockerfile): implement fallback mechanisms for apt update and install --- Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ad19e2f..a023964 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,8 +41,25 @@ if url: finally: sock.close() PY -apt-get update -apt-get install -y --no-install-recommends build-essential gcc libpq-dev +APT_PROXY_CONFIG=/etc/apt/apt.conf.d/01proxy + +apt_update_with_fallback() { + if ! apt-get update; then + rm -f "$APT_PROXY_CONFIG" + apt-get update + fi +} + +apt_install_with_fallback() { + if ! apt-get install -y --no-install-recommends "$@"; then + rm -f "$APT_PROXY_CONFIG" + apt-get update + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_update_with_fallback +apt_install_with_fallback build-essential gcc libpq-dev pip install --upgrade pip pip wheel --no-deps --wheel-dir /wheels -r requirements.txt apt-get purge -y --auto-remove build-essential gcc @@ -88,8 +105,25 @@ if url: finally: sock.close() PY -apt-get update -apt-get install -y --no-install-recommends libpq5 +APT_PROXY_CONFIG=/etc/apt/apt.conf.d/01proxy + +apt_update_with_fallback() { + if ! apt-get update; then + rm -f "$APT_PROXY_CONFIG" + apt-get update + fi +} + +apt_install_with_fallback() { + if ! apt-get install -y --no-install-recommends "$@"; then + rm -f "$APT_PROXY_CONFIG" + apt-get update + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_update_with_fallback +apt_install_with_fallback libpq5 rm -rf /var/lib/apt/lists/* EOF