From 277595621c83c2ab2a613478a625c7c5b64bccc9 Mon Sep 17 00:00:00 2001 From: Huarch Date: Tue, 21 Jul 2026 15:50:20 +0800 Subject: [PATCH] Speed up Docker image dependency install --- Dockerfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0e4226c..626da5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,21 +2,27 @@ FROM condaforge/miniforge3:latest WORKDIR /app +ARG APT_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/ubuntu +ARG CONDA_CHANNEL=https://mirrors.bfsu.edu.cn/anaconda/pkgs/main +ARG PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple + ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV MPLBACKEND=Agg ENV APP_ENV=production ENV DEBUG=false -RUN apt-get update \ +RUN sed -i "s|http://archive.ubuntu.com/ubuntu|${APT_MIRROR}|g; s|http://security.ubuntu.com/ubuntu|${APT_MIRROR}|g" /etc/apt/sources.list.d/ubuntu.sources \ + && apt-get update \ && apt-get install -y --no-install-recommends fontconfig fonts-noto-cjk \ && fc-cache -fv \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . -RUN mamba create -n demo python=3.12 -y \ - && conda run -n demo python -m pip install --no-cache-dir -r requirements.txt \ +RUN mamba create -n demo --override-channels -c "${CONDA_CHANNEL}" python=3.12 -y \ + && python -m pip install --no-cache-dir -i "${PIP_INDEX_URL}" uv \ + && uv pip install --python /opt/conda/envs/demo/bin/python --no-cache -i "${PIP_INDEX_URL}" -r requirements.txt \ && conda clean -afy COPY app ./app