|
|
@@ -83,7 +83,7 @@ $tmuxSession = "dbx"
|
|
|
|
|
|
## 国内加速优化
|
|
|
|
|
|
-脚本会自动修改 Dockerfile,应用以下三项国内加速:
|
|
|
+脚本会自动修改 Dockerfile,应用以下四项国内加速:
|
|
|
|
|
|
### 1. Docker 基础镜像加速
|
|
|
|
|
|
@@ -121,22 +121,38 @@ pip install -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.al
|
|
|
|
|
|
**实现方式**:使用 `sed` 全局替换 Dockerfile 中的 `pip install`。
|
|
|
|
|
|
+### 4. Poetry 源加速(阿里云)
|
|
|
+
|
|
|
+通过创建全局 pip 配置文件,让 Poetry 底层下载包时也使用阿里云源:
|
|
|
+
|
|
|
+```bash
|
|
|
+# 在 Dockerfile 中插入
|
|
|
+RUN mkdir -p /root/.config/pip && printf "[global]\nindex-url = https://mirrors.aliyun.com/pypi/simple/\ntrusted-host = mirrors.aliyun.com\n" > /root/.config/pip/pip.conf
|
|
|
+```
|
|
|
+
|
|
|
+**实现方式**:在 `FROM` 行后插入创建 pip 配置文件的 `RUN` 命令。
|
|
|
+
|
|
|
## Dockerfile 修改示例
|
|
|
|
|
|
原始 Dockerfile:
|
|
|
+
|
|
|
```dockerfile
|
|
|
FROM python:3.11-slim
|
|
|
RUN apt-get update && apt-get install -y gcc
|
|
|
RUN pip install poetry==1.7.1
|
|
|
+RUN poetry install
|
|
|
```
|
|
|
|
|
|
修改后:
|
|
|
+
|
|
|
```dockerfile
|
|
|
ARG DOCKER_MIRROR=docker.io
|
|
|
FROM ${DOCKER_MIRROR}/library/python:3.11-slim
|
|
|
+RUN mkdir -p /root/.config/pip && printf "[global]\nindex-url = https://mirrors.aliyun.com/pypi/simple/\ntrusted-host = mirrors.aliyun.com\n" > /root/.config/pip/pip.conf
|
|
|
RUN sed -i "s|http://deb.debian.org|https://mirrors.aliyun.com|g" /etc/apt/sources.list.d/debian.sources 2>/dev/null || true
|
|
|
RUN apt-get update && apt-get install -y gcc
|
|
|
RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com poetry==1.7.1
|
|
|
+RUN poetry install
|
|
|
```
|
|
|
|
|
|
## 查看构建进度
|