From 6ab601203263dda054adb02c2aff8fa33c702aa2 Mon Sep 17 00:00:00 2001 From: "mingsheng.li" Date: Fri, 25 Jul 2025 14:32:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AEBE=E7=9A=84=E6=89=93=E5=8C=85?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=88=A9?= =?UTF-8?q?=E7=94=A8pip=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 662c772..227d2d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,38 @@ +FROM harbor.dc.teramesh.cn/library/buildbase-python:3.11-slim AS builder + +# install python packages +ARG PIP_INDEX_URL +ENV PIP_INDEX_URL=$PIP_INDEX_URL + +COPY requirements.txt /requirements.txt +RUN --mount=type=cache,target=/root/.cache/pip pip install --no-warn-script-location --user --default-timeout 90 -r /requirements.txt + + FROM harbor.dc.teramesh.cn/library/deploybase-python:3.11-slim +ENV PATH=/root/.local/bin:$PATH + # 设置环境变量 ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 -# 安装系统依赖 -RUN apt-get update && apt-get install -y \ - gcc \ - libpq-dev \ - && rm -rf /var/lib/apt/lists/* +## 安装系统依赖 +#RUN apt-get update && apt-get install -y \ +# gcc \ +# libpq-dev \ +# && rm -rf /var/lib/apt/lists/* # 设置工作目录 WORKDIR /app -# 复制依赖文件并安装 -COPY requirements.txt . -#RUN --mount=type=cache,target=/root/.cache/pip pip install --no-cache-dir -r requirements.txt -RUN --mount=type=cache,target=/root/.cache/pip pip install --no-warn-script-location --user --default-timeout 90 -r requirements.txt +# copy packages +COPY --from=builder /root/.local /root/.local +COPY --from=builder /root/.pyarmor /root/.pyarmor + +## 复制依赖文件并安装 +#COPY requirements.txt . +##RUN --mount=type=cache,target=/root/.cache/pip pip install --no-cache-dir -r requirements.txt +#RUN --mount=type=cache,target=/root/.cache/pip pip install --no-warn-script-location --user --default-timeout 90 -r requirements.txt # 复制应用代码 COPY . .