# Conda base with VMTK FROM continuumio/miniconda3:latest WORKDIR /app # VTK requires OpenGL system libraries which aren't in the base miniconda image RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 libglib2.0-0 libsm6 libxrender1 libxext6 libosmesa6 \ && rm -rf /var/lib/apt/lists/* # Create the vmtk conda environment COPY environment.yml . RUN conda env create -f environment.yml && conda clean -afy # Verify the VMTK install: SetInputData must exist on VMTK filter objects RUN conda run -n vmtk_env python -c "import vtk; print('VTK', vtk.vtkVersion.GetVTKVersion()); from vmtk import vtkvmtkMiscPython as m; f = m.vtkvmtkPolyDataNetworkExtraction(); assert hasattr(f, 'SetInputData'), 'SetInputData missing - ABI mismatch'; print('VMTK SetInputData OK')" # Install Flask + CORS + gunicorn inside the vmtk_env RUN conda run -n vmtk_env pip install --no-cache-dir flask flask-cors gunicorn # Copy the backend source code COPY centerline_extraction.py ostium_detection.py endograft_generation.py server.py ./ # Hugging Face Spaces expects port 7860, server.py reads PORT from env ENV PORT=7860 EXPOSE 7860 # Run with gunicorn for production stability, timeout 600 allows up to 10 minutes per request (Voronoi can be slow) CMD ["conda", "run", "--no-capture-output", "-n", "vmtk_env", \ "gunicorn", "server:app", \ "--bind", "0.0.0.0:7860", \ "--timeout", "600", \ "--workers", "1", \ "--log-level", "info"]