Преглед изворни кода

refactor(docker): 替换 Dockerfile 所有境外下载为国内镜像源

- GitHub (CMake/s6-overlay/Prometheus/Skopeo) → gh-proxy.com
- Go 下载 → golang.google.cn
- Grafana → 清华源
- get-pip.py → gh-proxy 代理
- PostgreSQL apt → 清华源
- Ubuntu apt → 清华源
- PyPI → 清华源
- GOPROXY → goproxy.cn
- pci.ids → 清华源
- Launchpad PPA → USTC 代理
kinglee пре 2 недеља
родитељ
комит
4eea74d34d
1 измењених фајлова са 22 додато и 16 уклоњено
  1. 22 16
      pack/Dockerfile

+ 22 - 16
pack/Dockerfile

@@ -56,6 +56,10 @@ ENV DEBIAN_FRONTEND=noninteractive \
 RUN <<EOF
     # Tools
 
+    # Use Tsinghua mirrors for Ubuntu
+    sed -i 's|//archive.ubuntu.com|//mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
+    sed -i 's|//security.ubuntu.com|//mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
+
     # Refresh
     apt-get update -y && apt-get install -y --no-install-recommends \
         software-properties-common apt-transport-https \
@@ -134,7 +138,7 @@ RUN <<EOF
     # Install
     apt-get install -y --no-install-recommends \
         make ninja-build pkg-config ccache
-    curl --retry 3 --retry-connrefused -fL "https://github.com/Kitware/CMake/releases/download/v3.31.7/cmake-3.31.7-linux-$(uname -m).tar.gz" | tar -zx -C /usr --strip-components 1
+    curl --retry 3 --retry-connrefused -fL "https://gh-proxy.com/https://github.com/Kitware/CMake/releases/download/v3.31.7/cmake-3.31.7-linux-$(uname -m).tar.gz" | tar -zx -C /usr --strip-components 1
 
     # Install dependencies
     apt-get install -y --no-install-recommends \
@@ -174,10 +178,12 @@ RUN <<EOF
         exit 0
     fi
 
-    # Add deadsnakes PPA for Python versions
+    # Add deadsnakes PPA for Python versions (use Tsinghua mirror)
     for i in 1 2 3; do
-        add-apt-repository -y ppa:deadsnakes/ppa && break || { echo "Attempt $i failed, retrying in 5s..."; sleep 5; }
+        add-apt-repository -y ppa:deadsnakes/ppa --yes && break || { echo "Attempt $i failed, retrying in 5s..."; sleep 5; }
     done
+    # Replace PPA with Tsinghua mirror
+    sed -i 's|ppa.launchpadcontent.net|launchpad.proxy.ustclug.org|g' /etc/apt/sources.list.d/*.list
     apt-get update -y
 
     # Install
@@ -196,7 +202,7 @@ RUN <<EOF
     # Update alternatives
     if [[ -f /etc/alternatives/python3 ]]; then update-alternatives --remove-all python3; fi; update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1
     if [[ -f /etc/alternatives/python ]]; then update-alternatives --remove-all python; fi; update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1
-    curl -sS "https://bootstrap.pypa.io/get-pip.py" | python${PYTHON_VERSION}
+    curl -sS "https://gh-proxy.com/https://raw.githubusercontent.com/pypa/get-pip/main/get-pip.py" | python${PYTHON_VERSION}
     if [[ -f /etc/alternatives/2to3 ]]; then update-alternatives --remove-all 2to3; fi; update-alternatives --install /usr/bin/2to3 2to3 /usr/bin/2to3${PYTHON_VERSION} 1 || true
     if [[ -f /etc/alternatives/pydoc3 ]]; then update-alternatives --remove-all pydoc3; fi; update-alternatives --install /usr/bin/pydoc3 pydoc3 /usr/bin/pydoc${PYTHON_VERSION} 1 || true
     if [[ -f /etc/alternatives/idle3 ]]; then update-alternatives --remove-all idle3; fi; update-alternatives --install /usr/bin/idle3 idle3 /usr/bin/idle${PYTHON_VERSION} 1 || true
@@ -241,7 +247,7 @@ hatchling
 py-spy
 poetry
 EOT
-    pip install -r /tmp/requirements.txt
+    pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple -r /tmp/requirements.txt
 
     # Cleanup
     rm -rf /var/tmp/* \
@@ -263,7 +269,7 @@ RUN set -eux; \
         ;; \
     esac; \
     echo "Installing s6-overlay ${S6_OVERLAY_VERSION} for arch: ${S6_ARCH} (from TARGETARCH=${TARGETARCH})"; \
-    base_url="https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}"; \
+    base_url="https://gh-proxy.com/https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}"; \
     for pkg in noarch ${S6_ARCH}; do \
         wget -q -O "/tmp/s6-overlay-${pkg}.tar.xz" "${base_url}/s6-overlay-${pkg}.tar.xz"; \
     done \
@@ -316,11 +322,11 @@ RUN set -eux; \
 RUN <<EOF
     set -eux
 
-    # Add PostgreSQL APT repository
-    wget -O /tmp/ACCC4CF8.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc \
+    # Use Tsinghua mirror for PostgreSQL APT repository
+    wget -O /tmp/ACCC4CF8.asc https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/apt/ACCC4CF8.asc \
         && gpg --dearmor /tmp/ACCC4CF8.asc \
         && mv /tmp/ACCC4CF8.asc.gpg /usr/share/keyrings/postgresql-archive-keyring.gpg \
-        && echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
+        && echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
 
     # Install
     apt-get update -y && apt-get install -y --no-install-recommends \
@@ -390,13 +396,13 @@ COPY docker-compose/grafana/grafana_dashboards/ /etc/dashboards/
 
 ## Install Skopeo
 
-ARG GOPROXY="https://proxy.golang.org,direct"
+ARG GOPROXY="https://goproxy.cn,direct"
 
 RUN <<EOF
     # Skopeo
 
     # Install Go
-    curl --retry 3 --retry-connrefused -fL "https://go.dev/dl/go1.23.3.${TARGETOS}-${TARGETARCH}.tar.gz" | tar -zx -C /usr/local
+    curl --retry 3 --retry-connrefused -fL "https://golang.google.cn/dl/go1.23.3.${TARGETOS}-${TARGETARCH}.tar.gz" | tar -zx -C /usr/local
     export PATH="/usr/local/go/bin:${PATH}"
     export GOPROXY="${GOPROXY}"
     export
@@ -404,7 +410,7 @@ RUN <<EOF
     # Download
     git -C /tmp clone --recursive --shallow-submodules \
         --depth 1 --branch v1.20.0 --single-branch \
-        https://github.com/containers/skopeo.git skopeo
+        https://gh-proxy.com/https://github.com/containers/skopeo.git skopeo
 
     # Build and install
     pushd /tmp/skopeo \
@@ -464,14 +470,14 @@ RUN <<EOF
     esac
 
     curl --retry 3 --retry-connrefused -fL \
-        "https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-${PROM_ARCH}.tar.gz" \
+        "https://gh-proxy.com/https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-${PROM_ARCH}.tar.gz" \
         | tar -zx -C /opt
     mv "/opt/prometheus-${PROMETHEUS_VERSION}.linux-${PROM_ARCH}" /opt/prometheus
     ln -s /opt/prometheus/prometheus /usr/local/bin/prometheus
     ln -s /opt/prometheus/promtool /usr/local/bin/promtool
 
     curl --retry 3 --retry-connrefused -fL \
-        "https://dl.grafana.com/oss/release/grafana-${GRAFANA_VERSION}.linux-${GRAFANA_ARCH}.tar.gz" \
+        "https://mirrors.tuna.tsinghua.edu.cn/grafana/oss/grafana-${GRAFANA_VERSION}.linux-${GRAFANA_ARCH}.tar.gz" \
         | tar -zx -C /opt
     mv "/opt/grafana-${GRAFANA_VERSION}" /opt/grafana
     ln -s /opt/grafana/bin/grafana-server /usr/local/bin/grafana-server
@@ -510,7 +516,7 @@ RUN --mount=type=cache,target=/root/.cache \
         WHEEL_PACKAGE="$(ls /workspace/gpustack/dist/*.whl)[audio]";
     fi
 
-    uv pip install --no-build-isolation --extra-index-url https://download.pytorch.org/whl/cpu/ \
+    uv pip install --no-build-isolation --extra-index-url https://download.pytorch.org/whl/cpu/ --index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple \
         ${WHEEL_PACKAGE}
 
     # Download tools
@@ -528,7 +534,7 @@ RUN --mount=type=cache,target=/root/.cache \
 
     # Try to update PCI IDs
     if ! update-pciids; then
-        curl -o /usr/share/misc/pci.ids https://pci-ids.ucw.cz/v2.2/pci.ids || true
+        curl -o /usr/share/misc/pci.ids https://mirrors.tuna.tsinghua.edu.cn/misc/pci.ids || true
     fi
 
     # Cleanup