70 lines
2.3 KiB
Docker
70 lines
2.3 KiB
Docker
# 构建阶段
|
|
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04 AS builder
|
|
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV TZ=Asia/Shanghai
|
|
|
|
# 配置apt源为清华源
|
|
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
|
|
sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
software-properties-common \
|
|
curl \
|
|
build-essential \
|
|
&& add-apt-repository ppa:deadsnakes/ppa \
|
|
&& apt-get update \
|
|
&& apt-get install -y python3.11 python3.11-dev python3.11-distutils \
|
|
&& curl -sS https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
|
|
&& python3.11 get-pip.py -i https://pypi.tuna.tsinghua.edu.cn/simple \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 设置Python 3.11为默认版本
|
|
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
|
|
update-alternatives --set python3 /usr/bin/python3.11
|
|
|
|
WORKDIR /producer_chat
|
|
|
|
# 配置pip源为清华源
|
|
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
|
|
|
|
# 安装依赖
|
|
COPY requirements.txt .
|
|
RUN python3 -m pip install --no-cache-dir -r requirements.txt
|
|
|
|
# 最终阶段
|
|
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV TZ=Asia/Shanghai
|
|
|
|
# 配置apt源为清华源
|
|
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
|
|
sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
ffmpeg \
|
|
libgl1-mesa-glx \
|
|
python3.11 \
|
|
python3.11-distutils \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 设置Python 3.11为默认版本
|
|
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
|
|
update-alternatives --set python3 /usr/bin/python3.11
|
|
|
|
WORKDIR /producer_chat
|
|
|
|
# 从构建阶段复制Python包
|
|
COPY --from=builder /usr/local/lib/python3.11/dist-packages /usr/local/lib/python3.11/dist-packages
|
|
|
|
# 复制应用代码
|
|
COPY . .
|
|
|
|
# 创建必要的目录
|
|
RUN mkdir -p /obscura/task/upload /obscura/task/result /obscura/task/audio_files
|
|
|
|
CMD ["python3", "producer_chat.py"] |