fix: 优化内容
This commit is contained in:
62
Dockerfile
62
Dockerfile
@@ -1,6 +1,7 @@
|
||||
FROM python:3.10-slim
|
||||
FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04 AS builder
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
@@ -10,26 +11,53 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# ffmpeg is required for MoviePy (audio duration + encoding).
|
||||
RUN if [ -f /etc/apt/sources.list ]; then \
|
||||
sed -i 's|http://deb.debian.org/debian|https://mirrors.tuna.tsinghua.edu.cn/debian|g; s|http://security.debian.org/debian-security|https://mirrors.tuna.tsinghua.edu.cn/debian-security|g' /etc/apt/sources.list; \
|
||||
fi \
|
||||
&& if [ -f /etc/apt/sources.list.d/debian.sources ]; then \
|
||||
sed -i 's|http://deb.debian.org/debian|https://mirrors.tuna.tsinghua.edu.cn/debian|g; s|http://security.debian.org/debian-security|https://mirrors.tuna.tsinghua.edu.cn/debian-security|g' /etc/apt/sources.list.d/debian.sources; \
|
||||
fi \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||
ffmpeg \
|
||||
fonts-dejavu-core \
|
||||
nodejs \
|
||||
npm \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# Base deps + Python 3.10 + Node.js 20.x
|
||||
RUN sed -i 's|http://archive.ubuntu.com/ubuntu|https://mirrors.tuna.tsinghua.edu.cn/ubuntu|g; s|http://security.ubuntu.com/ubuntu|https://mirrors.tuna.tsinghua.edu.cn/ubuntu|g' /etc/apt/sources.list \
|
||||
&& apt-get -o Acquire::Retries=5 update \
|
||||
&& apt-get -o Acquire::Retries=5 install -y --no-install-recommends --fix-missing \
|
||||
ca-certificates curl gnupg \
|
||||
python3.10 python3.10-distutils python3-pip \
|
||||
ffmpeg fonts-dejavu-core \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||
&& apt-get -o Acquire::Retries=5 install -y --no-install-recommends --fix-missing nodejs \
|
||||
&& ln -sf /usr/bin/python3.10 /usr/local/bin/python \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements.txt /app/requirements.txt
|
||||
RUN pip install -r /app/requirements.txt
|
||||
RUN python3.10 -m pip install -r /app/requirements.txt
|
||||
|
||||
COPY server/package.json server/package-lock.json /app/server/
|
||||
RUN cd /app/server && npm ci --omit=dev
|
||||
|
||||
COPY . /app
|
||||
|
||||
RUN cd /app/server && npm i --omit=dev
|
||||
FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04 AS runtime
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||
PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn \
|
||||
NPM_CONFIG_REGISTRY=https://registry.npmmirror.com
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN sed -i 's|http://archive.ubuntu.com/ubuntu|https://mirrors.tuna.tsinghua.edu.cn/ubuntu|g; s|http://security.ubuntu.com/ubuntu|https://mirrors.tuna.tsinghua.edu.cn/ubuntu|g' /etc/apt/sources.list \
|
||||
&& apt-get -o Acquire::Retries=5 update \
|
||||
&& apt-get -o Acquire::Retries=5 install -y --no-install-recommends --fix-missing \
|
||||
ca-certificates \
|
||||
python3.10 python3.10-distutils python3-pip \
|
||||
ffmpeg fonts-dejavu-core \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||
&& apt-get -o Acquire::Retries=5 install -y --no-install-recommends --fix-missing nodejs \
|
||||
&& ln -sf /usr/bin/python3.10 /usr/local/bin/python \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=builder /usr/local/lib/python3.10 /usr/local/lib/python3.10
|
||||
COPY --from=builder /usr/local/bin /usr/local/bin
|
||||
COPY --from=builder /app /app
|
||||
|
||||
EXPOSE 3000
|
||||
CMD ["node", "/app/server/index.js"]
|
||||
|
||||
Reference in New Issue
Block a user