diff options
-rw-r--r-- | Dockerfile | 5 | ||||
-rwxr-xr-x | configure-mirror | 49 |
2 files changed, 53 insertions, 1 deletions
@@ -9,12 +9,15 @@ LABEL maintainer="Gerd Hoffmann <kraxel@redhat.com>" \ USER root -RUN dnf update -y && \ +COPY configure-mirror /usr/local/bin +RUN /usr/local/bin/configure-mirror && \ + dnf update -y && \ dnf install -y \ 'dnf-command(builddep)' \ 'dnf-command(config-manager)' \ https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \ && \ + /usr/local/bin/configure-mirror && \ dnf config-manager --set-enabled PowerTools && \ dnf install -y \ fedora-packager tito \ diff --git a/configure-mirror b/configure-mirror new file mode 100755 index 0000000..a66ec01 --- /dev/null +++ b/configure-mirror @@ -0,0 +1,49 @@ +#!/bin/sh + +function set_baseurl() { + local furl="$1" + local turl="$2" + local name="$3" + local file + + if test "$turl" = ""; then + echo "# no mirror: $furl (env \$$name)" + return + fi + + for file in /etc/yum.repos.d/*.repo; do + if test ! -f "${file}.dist"; then + cp "${file}" "${file}.dist" + fi + grep -q -e "baseurl=$furl" "${file}.dist" || continue + echo "# mirror: $furl -> $turl ($file)" + sed -e 's/^mirrorlist/#mirrorlist/' \ + -e 's/^metalink/#metalink/' \ + -e 's/^#baseurl/baseurl/' \ + -e "s|baseurl=${furl}|baseurl=${turl}|" \ + < "${file}.dist" > "$file" + done +} + +# +# use fixed (configurable) mirror. +# be cache proxy friendly. +# +set_baseurl http://mirror.centos.org/centos/ "${CENTOS_MIRROR}" CENTOS_MIRROR +set_baseurl http://download.fedoraproject.org/pub/epel/ "${EPEL_MIRROR}" EPEL_MIRROR +set_baseurl http://download.fedoraproject.org/pub/fedora/linux/ "${FEDORA_MIRROR}" FEDORA_MIRROR +set_baseurl http://download.example/pub/fedora/linux/ "${FEDORA_MIRROR}" FEDORA_MIRROR + +# +# no parallel downloads please. +# +if test -f /etc/dnf/dnf.conf; then + grep -q max_parallel_downloads /etc/dnf/dnf.conf ||\ + echo max_parallel_downloads=1 >> /etc/dnf/dnf.conf +fi +if test -f /etc/yum.conf; then + grep -q max_connections /etc/yum.conf ||\ + echo max_connections=1 >> /etc/yum.conf +fi + +exit 0 |