From 3ed3d34900744f2e2a6cf6a9537a04e09e46036f Mon Sep 17 00:00:00 2001 From: renjue Date: Sat, 9 May 2026 16:32:11 +0800 Subject: [PATCH] Speed up Docker apt install with configurable mirror. Add APT_MIRROR build arg to switch Debian source before apt-get update, and document faster build command using BuildKit and host network. Co-authored-by: Cursor --- Dockerfile | 3 +++ README.md | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/Dockerfile b/Dockerfile index 9748d24..c53bf0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,10 @@ FROM node:20-bookworm-slim +ARG APT_MIRROR=mirrors.aliyun.com ENV DEBIAN_FRONTEND=noninteractive +RUN sed -i "s|deb.debian.org|${APT_MIRROR}|g; s|security.debian.org|${APT_MIRROR}|g" /etc/apt/sources.list.d/debian.sources + RUN apt-get update \ && apt-get install -y --no-install-recommends python3 python3-pip ca-certificates git \ && rm -rf /var/lib/apt/lists/* diff --git a/README.md b/README.md index 382411a..db86574 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,14 @@ npm run dev docker build -t media-crawler:latest . ``` +构建较慢时可使用加速参数(BuildKit + host 网络 + 可选 apt 镜像): + +```bash +DOCKER_BUILDKIT=1 docker build --network=host \ + --build-arg APT_MIRROR=mirrors.aliyun.com \ + -t media-crawler:latest . +``` + ### 运行容器 ```bash