Files
operating-room-monitor-server/backend/Dockerfile
Kevin 704a83607d Fix MediaPipe doctor recognition missing libGLESv2 in Docker.
Install Mesa/GLVND GLES/EGL runtime libraries and verify mediapipe import at image build time so headless doctor pose inference no longer fails on libGLESv2.so.2.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 11:57:52 +08:00

75 lines
2.8 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# syntax=m.daocloud.io/docker.io/docker/dockerfile:1.7
# ---------------------------------------------------------------------------
# 禁止「FROM python:...」简写 — 会直连 docker.io / registry-1.docker.io。
# Python 使用 DaoCloud 增加前缀形式https://github.com/DaoCloud/public-image-mirror
# 勿用裸 tag「3.13」;须 3.13-slim-bookworm。
# ---------------------------------------------------------------------------
FROM m.daocloud.io/docker.io/library/python:3.13-slim-bookworm
# Debian bookworm: use Aliyun mirror for apt (default snapshot points at deb.debian.org).
RUN sed -i \
-e 's|http://deb.debian.org/debian-security|https://mirrors.aliyun.com/debian-security|g' \
-e 's|http://deb.debian.org/debian|https://mirrors.aliyun.com/debian|g' \
/etc/apt/sources.list.d/debian.sources
# OpenCV / MediaPipe (doctor pose) need GLVND + Mesa GLES/EGL in slim images; omit X11/GUI stack.
RUN apt-get update && apt-get install -y --no-install-recommends \
docker.io \
ffmpeg \
fontconfig \
fonts-noto-cjk \
fonts-wqy-microhei \
libegl-mesa0 \
libegl1 \
libgbm1 \
libgl1 \
libgl1-mesa-dri \
libglx-mesa0 \
libgles2 \
libglib2.0-0 \
libgomp1 \
libxcb1 \
&& fc-cache -fv \
&& ldconfig \
&& ldconfig -p | grep -F 'libGLESv2.so.2' >/dev/null \
&& rm -rf /var/lib/apt/lists/*
# ghcr.io「增加前缀」形式与 kindest/node 示例一致)
COPY --from=m.daocloud.io/ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
ENV PYTHONUNBUFFERED=1 \
UV_COMPILE_BYTECODE=1 \
UV_HTTP_TIMEOUT=600 \
UV_LINK_MODE=copy \
TORCH_HOME=/root/.cache/torch
COPY pyproject.toml uv.lock main.py alembic.ini ./
COPY app ./app/
COPY alembic ./alembic/
# 离线批处理 / demo 直调 algorithm_subprocesses/5.15/main.py含 weights/
COPY algorithm_subprocesses ./algorithm_subprocesses/
# uv.lock pins full download URLs. Rewrite to mainland-accessible mirrors (same paths / hashes).
# PyPI: Tsinghua | PyTorch wheel index: 南大 (syncs download.pytorch.org / download-r2)
RUN sed -i \
-e 's|https://files.pythonhosted.org|https://pypi.tuna.tsinghua.edu.cn|g' \
-e 's|https://pypi.org/simple|https://pypi.tuna.tsinghua.edu.cn/simple|g' \
-e 's|https://download-r2.pytorch.org|https://mirrors.nju.edu.cn/pytorch|g' \
-e 's|https://download.pytorch.org|https://mirrors.nju.edu.cn/pytorch|g' \
uv.lock
ENV UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev && \
.venv/bin/python -c "import alembic" && \
.venv/bin/python -c "import mediapipe as mp; print('mediapipe', mp.__version__)"
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]