-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
83 lines (70 loc) · 2.79 KB
/
Dockerfile
File metadata and controls
83 lines (70 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# ============================================================================
# Eurus ERA5 Agent — Docker Image
# ============================================================================
# Single-stage build for HuggingFace Spaces + local docker-compose.
#
# Local usage:
# docker build -t eurus-web .
# docker run -p 7860:7860 --env-file .env eurus-web
#
# Or use docker-compose:
# docker compose up web
# ============================================================================
FROM python:3.12-slim
# System deps for scientific stack (numpy/scipy wheels, geopandas/shapely, matplotlib)
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc g++ \
libgeos-dev \
libproj-dev \
libffi-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js 20 for React frontend build
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python deps first (layer caching)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Build React frontend (separate layer for caching)
COPY frontend/package.json frontend/package-lock.json* frontend/
RUN cd frontend && npm ci
COPY frontend/ frontend/
RUN cd frontend && npm run build
# Copy project source
COPY pyproject.toml .
COPY src/ src/
COPY main.py .
COPY web/ web/
COPY tests/ tests/
COPY scripts/ scripts/
COPY assets/ assets/
COPY README.md LICENSE ./
# Install eurus package in editable mode
RUN pip install --no-cache-dir -e ".[agent,web]"
# Create dirs the agent expects
RUN mkdir -p /app/data/plots /app/.memory /app/logs
# Pre-download Natural Earth data for Cartopy coastlines
RUN python -c "import cartopy; cartopy.io.shapereader.natural_earth(resolution='110m', category='physical', name='coastline')" \
&& python -c "import cartopy; cartopy.io.shapereader.natural_earth(resolution='50m', category='physical', name='coastline')" \
&& python -c "import cartopy; cartopy.io.shapereader.natural_earth(resolution='110m', category='physical', name='land')" \
&& python -c "import cartopy; cartopy.io.shapereader.natural_earth(resolution='50m', category='physical', name='land')"
# Pre-import heavy modules at BUILD time to force compilation / bytecode caching.
# This avoids a 30+ minute first-import delay on HF Spaces' constrained free tier.
RUN python -c "\
import langchain; \
import langchain_openai; \
import arraylake; \
import icechunk; \
import xarray; \
import scipy; \
import matplotlib; \
import scgraph; \
print('All heavy modules pre-imported successfully')"
# Matplotlib: no GUI backend
ENV MPLBACKEND=Agg
# Ensure Python output is unbuffered (for docker logs)
ENV PYTHONUNBUFFERED=1
EXPOSE 7860
CMD ["uvicorn", "web.app:app", "--host", "0.0.0.0", "--port", "7860"]