我有以下多阶段构建将 pyrender 添加到 distroless continer
FROM debian:11-slim as build
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev \
wget git ca-certificates python python3-pip libglu1-mesa-dev freeglut3-dev && \
python3 -m venv /venv && \
/venv/bin/pip install --upgrade pip setuptools wheel
RUN /venv/bin/pip install pyrender pyopengl PyOpenGL_accelerate
FROM gcr.io/distroless/python3-debian11
COPY --from=build /usr/lib /usr/lib
COPY --from=build /usr/include /usr/include
COPY --from=build /venv /venv
如果我在里面运行 pyrenderdebian:11-slim
它一切正常但是当我将库移动到 distroless 并尝试运行时import pyrender
我得到
File "/venv/lib/python3.9/site-packages/OpenGL/platform/glx.py", line 20, in GL
raise ImportError("Unable to load OpenGL library", *err.args)
ImportError: ('Unable to load OpenGL library', 'GL: cannot open shared object file: No such file or directory', 'GL', None)
或者
File "/venv/lib/python3.9/site-packages/pyrender/platforms/egl.py", line 83, in get_device_by_index
raise ValueError('Invalid device ID ({})'.format(device_id, len(devices)))
ValueError: Invalid device ID (0)
我确实将环境变量设置为os.environ['PYOPENGL_PLATFORM'] = 'egl'
关于我做错了什么的任何指示?我想用 distroless 而不是 debian 映像运行它。