fix
This commit is contained in:
18
Dockerfile
18
Dockerfile
@@ -1,29 +1,27 @@
|
|||||||
FROM python:3.13-slim AS builder
|
FROM python:3.12.2-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 配置apt使用国内镜像源
|
# 配置apk使用清华镜像源
|
||||||
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
|
||||||
|
|
||||||
# 安装构建依赖
|
# 安装构建依赖
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apk add --no-cache build-base
|
||||||
build-essential \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# 复制依赖文件
|
# 复制依赖文件
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
|
|
||||||
# 使用国内镜像源安装依赖
|
# 使用清华镜像源安装依赖
|
||||||
RUN pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple \
|
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||||
&& pip install --no-cache-dir -r requirements.txt
|
&& pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
# 最终阶段
|
# 最终阶段
|
||||||
FROM python:3.13-slim
|
FROM python:3.12.2-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 从builder阶段复制Python包
|
# 从builder阶段复制Python包
|
||||||
COPY --from=builder /usr/local/lib/python3.13/site-packages/ /usr/local/lib/python3.13/site-packages/
|
COPY --from=builder /usr/local/lib/python3.12/site-packages/ /usr/local/lib/python3.12/site-packages/
|
||||||
COPY --from=builder /usr/local/bin/ /usr/local/bin/
|
COPY --from=builder /usr/local/bin/ /usr/local/bin/
|
||||||
|
|
||||||
# 复制应用代码
|
# 复制应用代码
|
||||||
|
|||||||
Reference in New Issue
Block a user