Dockerfile: python:3.11 base, cleaned up
Browse files- Dockerfile +16 -33
Dockerfile
CHANGED
|
@@ -1,50 +1,32 @@
|
|
| 1 |
-
FROM python:3.11
|
| 2 |
|
| 3 |
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
RUN echo "deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list \
|
| 7 |
-
&& echo "deb http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list \
|
| 8 |
-
&& echo "deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list
|
| 9 |
-
|
| 10 |
-
# Blender headless 运行所需的系统库
|
| 11 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 12 |
-
wget \
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
libxi6 \
|
| 16 |
-
libxext6 \
|
| 17 |
-
libxrender1 \
|
| 18 |
-
libxfixes3 \
|
| 19 |
-
libxxf86vm1 \
|
| 20 |
-
libxkbcommon0 \
|
| 21 |
-
libsm6 \
|
| 22 |
-
libgl1 \
|
| 23 |
-
libglu1-mesa \
|
| 24 |
&& rm -rf /var/lib/apt/lists/*
|
| 25 |
|
| 26 |
-
# 4.2
|
| 27 |
ARG BLENDER_VERSION=4.2.9
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
&& mv "/opt/blender-${BLENDER_VERSION}-linux-x64" /opt/blender \
|
| 33 |
-
&& rm /tmp/blender.tar.xz
|
| 34 |
-
|
| 35 |
ENV PATH="/opt/blender:${PATH}"
|
| 36 |
|
| 37 |
-
#
|
| 38 |
RUN useradd -m -u 1000 appuser
|
| 39 |
-
|
| 40 |
WORKDIR /app
|
| 41 |
|
| 42 |
COPY requirements.txt .
|
| 43 |
-
RUN pip install -
|
| 44 |
|
| 45 |
COPY app.py worker.py ./
|
| 46 |
|
| 47 |
-
# 运行时创建目录
|
| 48 |
RUN mkdir -p /data/jobs
|
| 49 |
ENV JOB_DIR=/data/jobs
|
| 50 |
ENV BLENDER_BIN=/opt/blender/blender
|
|
@@ -52,5 +34,6 @@ ENV JOB_TIMEOUT_SECONDS=180
|
|
| 52 |
|
| 53 |
EXPOSE 7860
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
| 1 |
+
FROM python:3.11
|
| 2 |
|
| 3 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 4 |
+
ENV PIP_NO_CACHE_DIR=1
|
| 5 |
|
| 6 |
+
# 系统依赖(python:3.11 基于 Debian bookworm,源完整)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 8 |
+
wget xz-utils ca-certificates \
|
| 9 |
+
libxi6 libxext6 libxrender1 libxfixes3 libxxf86vm1 \
|
| 10 |
+
libxkbcommon0 libsm6 libgl1 libglu1-mesa \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
+
# Blender 4.2 LTS
|
| 14 |
ARG BLENDER_VERSION=4.2.9
|
| 15 |
+
RUN wget -q "https://download.blender.org/release/Blender4.2/blender-${BLENDER_VERSION}-linux-x64.tar.xz" -O /tmp/blender.tar.xz \
|
| 16 |
+
&& tar -xf /tmp/blender.tar.xz -C /opt \
|
| 17 |
+
&& mv /opt/blender-${BLENDER_VERSION}-linux-x64 /opt/blender \
|
| 18 |
+
&& rm /tmp/blender.tar.xz
|
|
|
|
|
|
|
|
|
|
| 19 |
ENV PATH="/opt/blender:${PATH}"
|
| 20 |
|
| 21 |
+
# 非 root 用户
|
| 22 |
RUN useradd -m -u 1000 appuser
|
|
|
|
| 23 |
WORKDIR /app
|
| 24 |
|
| 25 |
COPY requirements.txt .
|
| 26 |
+
RUN pip install -r requirements.txt
|
| 27 |
|
| 28 |
COPY app.py worker.py ./
|
| 29 |
|
|
|
|
| 30 |
RUN mkdir -p /data/jobs
|
| 31 |
ENV JOB_DIR=/data/jobs
|
| 32 |
ENV BLENDER_BIN=/opt/blender/blender
|
|
|
|
| 34 |
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
+
# 运行时修权限(避免构建期 chown 失败)
|
| 38 |
+
CMD mkdir -p /data/jobs && chown -R appuser:appuser /data /app 2>/dev/null || true \
|
| 39 |
+
&& exec uvicorn app:app --host 0.0.0.0 --port 7860
|