# M3GNet FastMCP HuggingFace Space image FROM python:3.10-slim ENV PIP_NO_CACHE_DIR=1 \ HF_HUB_DISABLE_TELEMETRY=1 \ TF_CPP_MIN_LOG_LEVEL=2 \ CUDA_VISIBLE_DEVICES=-1 WORKDIR /app # System build/runtime dependencies for pymatgen, ASE, and TensorFlow RUN apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ git \ curl \ libopenblas-dev \ liblapack-dev \ libffi-dev \ libssl-dev \ ca-certificates \ && rm -rf /var/lib/apt/lists/* # Copy everything from the build context into the image COPY . /app # Staged installation to avoid dependency conflicts: # 1) Install TensorFlow 2.13 (requires numpy<=1.24.3) # 2) Install m3gnet with --no-deps, then its deps manually with compatible versions # 3) Install MCP service deps (needs pydantic v2) # 4) Force upgrade pydantic to v2 (pymatgen works fine with it at runtime) RUN pip install --upgrade pip # Stage 1: TensorFlow with compatible numpy RUN pip install --no-cache-dir tensorflow==2.13.0 numpy==1.24.3 # Stage 2: M3GNet and materials science stack RUN pip install --no-cache-dir \ ase==3.22.1 \ monty==2024.2.2 \ sympy \ spglib \ scipy \ matplotlib \ pandas \ networkx \ requests \ ruamel.yaml \ tabulate \ uncertainties # Install pymatgen with relaxed deps, then m3gnet RUN pip install --no-cache-dir --no-deps pymatgen==2024.2.20 \ && pip install --no-cache-dir --no-deps m3gnet==0.2.4 # Stage 3: MCP service dependencies RUN if [ -f "mcp_output/requirements.txt" ]; then \ pip install --no-cache-dir -r mcp_output/requirements.txt; \ elif [ -f "requirements.txt" ]; then \ pip install --no-cache-dir -r requirements.txt; \ fi # Stage 4: Ensure pydantic v2 for MCP (runtime compatible with pymatgen) RUN pip install --no-cache-dir --upgrade "pydantic>=2.0" EXPOSE 7860 CMD ["python", "/app/entrypoint.py"]