FROM ubuntu:22.04 ARG BLENDER_VERSION=5.0.1 ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 ENV BLENDER_VERSION=${BLENDER_VERSION} # Blender 5.x is mounted from the host at /opt/blender (see docker-compose.yml) ENV BLENDER_BIN=/opt/blender/blender # OSMesa for headless cadquery/VTK (no display needed) ENV PYOPENGL_PLATFORM=osmesa ENV VTK_DEFAULT_EGL=0 # Runtime libraries for cadquery/OCC + Blender 5.x headless RUN apt-get update && apt-get install -y --no-install-recommends \ python3-pip \ python3-dev \ libpq-dev \ gcc \ libxrender1 \ libxi6 \ libxkbcommon-x11-0 \ libsm6 \ libglib2.0-0 \ libgl1-mesa-glx \ libosmesa6 \ libgomp1 \ libxfixes3 \ libxrandr2 \ libxcursor1 \ libxinerama1 \ libwayland-client0 \ libwayland-cursor0 \ libwayland-egl1 \ libvulkan1 \ mesa-vulkan-drivers \ libegl1 \ libegl-mesa0 \ libgbm1 \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install backend Python dependencies (includes celery, sqlalchemy, fastapi, etc.) COPY pyproject.toml . RUN pip3 install --no-cache-dir -e . # Install cadquery (heavy — installed after backend deps for better layer caching) RUN pip3 install --no-cache-dir "cadquery>=2.4.0" # Copy render scripts COPY scripts/ /render-scripts/ # Version check script — fails fast if Blender < 5.0.1 COPY check_version.py /check_version.py # Copy app code (overridden by volume mount in docker-compose) COPY . . # Verify Blender version at build time if binary is available # (skipped during build since /opt/blender is a host mount) CMD ["bash", "-c", "python3 /check_version.py && celery -A app.tasks.celery_app worker --loglevel=info -Q thumbnail_rendering --concurrency=1"]