Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +69 -52
Dockerfile
CHANGED
|
@@ -1,52 +1,69 @@
|
|
| 1 |
-
# M3GNet FastMCP HuggingFace Space image
|
| 2 |
-
FROM python:3.10-slim
|
| 3 |
-
|
| 4 |
-
ENV PIP_NO_CACHE_DIR=1 \
|
| 5 |
-
HF_HUB_DISABLE_TELEMETRY=1 \
|
| 6 |
-
TF_CPP_MIN_LOG_LEVEL=2 \
|
| 7 |
-
CUDA_VISIBLE_DEVICES=-1
|
| 8 |
-
|
| 9 |
-
WORKDIR /app
|
| 10 |
-
|
| 11 |
-
# System build/runtime dependencies for pymatgen, ASE, and TensorFlow
|
| 12 |
-
RUN apt-get update \
|
| 13 |
-
&& apt-get install -y --no-install-recommends \
|
| 14 |
-
build-essential \
|
| 15 |
-
git \
|
| 16 |
-
curl \
|
| 17 |
-
libopenblas-dev \
|
| 18 |
-
liblapack-dev \
|
| 19 |
-
libffi-dev \
|
| 20 |
-
libssl-dev \
|
| 21 |
-
ca-certificates \
|
| 22 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 23 |
-
|
| 24 |
-
# Copy everything from the build context into the image
|
| 25 |
-
COPY . /app
|
| 26 |
-
|
| 27 |
-
#
|
| 28 |
-
#
|
| 29 |
-
#
|
| 30 |
-
#
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# M3GNet FastMCP HuggingFace Space image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
ENV PIP_NO_CACHE_DIR=1 \
|
| 5 |
+
HF_HUB_DISABLE_TELEMETRY=1 \
|
| 6 |
+
TF_CPP_MIN_LOG_LEVEL=2 \
|
| 7 |
+
CUDA_VISIBLE_DEVICES=-1
|
| 8 |
+
|
| 9 |
+
WORKDIR /app
|
| 10 |
+
|
| 11 |
+
# System build/runtime dependencies for pymatgen, ASE, and TensorFlow
|
| 12 |
+
RUN apt-get update \
|
| 13 |
+
&& apt-get install -y --no-install-recommends \
|
| 14 |
+
build-essential \
|
| 15 |
+
git \
|
| 16 |
+
curl \
|
| 17 |
+
libopenblas-dev \
|
| 18 |
+
liblapack-dev \
|
| 19 |
+
libffi-dev \
|
| 20 |
+
libssl-dev \
|
| 21 |
+
ca-certificates \
|
| 22 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 23 |
+
|
| 24 |
+
# Copy everything from the build context into the image
|
| 25 |
+
COPY . /app
|
| 26 |
+
|
| 27 |
+
# Staged installation to avoid dependency conflicts:
|
| 28 |
+
# 1) Install TensorFlow 2.13 (requires numpy<=1.24.3)
|
| 29 |
+
# 2) Install m3gnet with --no-deps, then its deps manually with compatible versions
|
| 30 |
+
# 3) Install MCP service deps (needs pydantic v2)
|
| 31 |
+
# 4) Force upgrade pydantic to v2 (pymatgen works fine with it at runtime)
|
| 32 |
+
|
| 33 |
+
RUN pip install --upgrade pip
|
| 34 |
+
|
| 35 |
+
# Stage 1: TensorFlow with compatible numpy
|
| 36 |
+
RUN pip install --no-cache-dir tensorflow==2.13.0 numpy==1.24.3
|
| 37 |
+
|
| 38 |
+
# Stage 2: M3GNet and materials science stack
|
| 39 |
+
RUN pip install --no-cache-dir \
|
| 40 |
+
ase==3.22.1 \
|
| 41 |
+
monty==2024.2.2 \
|
| 42 |
+
sympy \
|
| 43 |
+
spglib \
|
| 44 |
+
scipy \
|
| 45 |
+
matplotlib \
|
| 46 |
+
pandas \
|
| 47 |
+
networkx \
|
| 48 |
+
requests \
|
| 49 |
+
ruamel.yaml \
|
| 50 |
+
tabulate \
|
| 51 |
+
uncertainties
|
| 52 |
+
|
| 53 |
+
# Install pymatgen with relaxed deps, then m3gnet
|
| 54 |
+
RUN pip install --no-cache-dir --no-deps pymatgen==2024.2.20 \
|
| 55 |
+
&& pip install --no-cache-dir --no-deps m3gnet==0.2.4
|
| 56 |
+
|
| 57 |
+
# Stage 3: MCP service dependencies
|
| 58 |
+
RUN if [ -f "mcp_output/requirements.txt" ]; then \
|
| 59 |
+
pip install --no-cache-dir -r mcp_output/requirements.txt; \
|
| 60 |
+
elif [ -f "requirements.txt" ]; then \
|
| 61 |
+
pip install --no-cache-dir -r requirements.txt; \
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# Stage 4: Ensure pydantic v2 for MCP (runtime compatible with pymatgen)
|
| 65 |
+
RUN pip install --no-cache-dir --upgrade "pydantic>=2.0"
|
| 66 |
+
|
| 67 |
+
EXPOSE 7860
|
| 68 |
+
|
| 69 |
+
CMD ["python", "/app/entrypoint.py"]
|