SEUyishu commited on
Commit
bb3d4d2
·
verified ·
1 Parent(s): 05199c0

Update Dockerfile

Browse files
Files changed (1) hide show
  1. 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
- # Install the core M3GNet library. The logic below works for both
28
- # "full repository" contexts (with setup.py at root) and the case where
29
- # the repo lives in a nested m3gnet/ directory. If neither is present we
30
- # fall back to installing the published package from PyPI.
31
- RUN set -ex \
32
- && pip install --upgrade pip \
33
- && if [ -f "setup.py" ] || [ -f "pyproject.toml" ]; then \
34
- if [ -f "requirements.txt" ]; then pip install --no-cache-dir -r requirements.txt; fi && \
35
- pip install --no-cache-dir .; \
36
- elif [ -f "m3gnet/setup.py" ] || [ -f "m3gnet/pyproject.toml" ]; then \
37
- if [ -f "m3gnet/requirements.txt" ]; then pip install --no-cache-dir -r m3gnet/requirements.txt; fi && \
38
- pip install --no-cache-dir ./m3gnet; \
39
- else \
40
- pip install --no-cache-dir m3gnet==0.2.4; \
41
- fi
42
-
43
- # Install MCP service dependencies
44
- RUN if [ -f "mcp_output/requirements.txt" ]; then \
45
- pip install --no-cache-dir -r mcp_output/requirements.txt; \
46
- elif [ -f "requirements.txt" ]; then \
47
- pip install --no-cache-dir -r requirements.txt; \
48
- fi
49
-
50
- EXPOSE 7860
51
-
52
- CMD ["python", "/app/entrypoint.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"]