videoNote / backend /Dockerfile.gpu
zhoujiaangyao
deploy videomemo backend to HF Space
6cfe55f
Raw
History Blame Contribute Delete
1.99 kB
# 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
# 飞书「推送方式 = lark-cli / auto」时需要官方 lark CLI(npm 包 @larksuite/cli,二进制名 lark-cli)。
# Ubuntu 22.04 自带 apt 的 Node 太旧(v12)跑不动新 CLI,这里用 NodeSource 装 Node 20。
# 走 REST 直连推送则用不到,可按需删除本段以瘦身镜像。凭证由后端运行时经环境变量注入,不写死。
ARG NPM_REGISTRY=https://registry.npmmirror.com
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y --no-install-recommends nodejs && \
npm config set registry ${NPM_REGISTRY} && \
npm install -g @larksuite/cli && \
rm -rf /var/lib/apt/lists/* /root/.npm && \
(lark-cli --version || true)
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"]