30 lines
1.3 KiB
Docker
30 lines
1.3 KiB
Docker
# BASE_REGISTRY 默认走 docker.io;国内可换 daocloud / 阿里云镜像(注意所选镜像需支持 nvidia/cuda 命名空间)
|
|
ARG BASE_REGISTRY=docker.io
|
|
FROM ${BASE_REGISTRY}/nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
|
|
|
|
ARG APT_MIRROR=mirrors.tuna.tsinghua.edu.cn
|
|
ARG PIP_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
|
|
|
|
RUN rm -f /etc/apt/sources.list && \
|
|
rm -rf /etc/apt/sources.list.d/* && \
|
|
echo "deb https://${APT_MIRROR}/ubuntu jammy main restricted universe multiverse" > /etc/apt/sources.list && \
|
|
echo "deb https://${APT_MIRROR}/ubuntu jammy-updates main restricted universe multiverse" >> /etc/apt/sources.list && \
|
|
echo "deb https://${APT_MIRROR}/ubuntu jammy-security main restricted universe multiverse" >> /etc/apt/sources.list && \
|
|
apt-get update && \
|
|
apt-get install -y --no-install-recommends ffmpeg python3-pip curl && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV HF_ENDPOINT=https://hf-mirror.com
|
|
|
|
WORKDIR /app
|
|
|
|
# 先复制 requirements.txt 利用层缓存
|
|
COPY ./backend/requirements.txt /app/requirements.txt
|
|
RUN pip install --no-cache-dir -i ${PIP_INDEX} -r requirements.txt && \
|
|
pip install --no-cache-dir -i ${PIP_INDEX} 'transformers[torch]>=4.23'
|
|
|
|
# 再复制应用代码
|
|
COPY ./backend /app
|
|
|
|
CMD ["python3", "main.py"]
|