deploy docker
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# 构建阶段
|
||||
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
|
||||
|
||||
# 安装系统依赖和Python
|
||||
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 \
|
||||
&& rm -rf /var/lib/apt/lists/* get-pip.py
|
||||
|
||||
# 设置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
|
||||
|
||||
# 配置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 \
|
||||
software-properties-common \
|
||||
&& add-apt-repository ppa:deadsnakes/ppa \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y python3.11 python3.11-distutils \
|
||||
&& 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
|
||||
|
||||
# 从构建阶段复制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
|
||||
|
||||
CMD ["python3", "producer.py"]
|
||||
Reference in New Issue
Block a user