File size: 2,405 Bytes
e1d420c
 
ae74af5
 
 
 
 
 
06a727e
ae74af5
 
e1d420c
 
 
 
 
 
 
9b79e73
129590a
9b79e73
 
8126c31
e1d420c
06a727e
 
 
 
 
 
 
 
 
70f43a7
d441ef4
70fbdf4
 
 
ae74af5
e1d420c
 
 
 
 
 
a2ab224
e1d420c
 
 
 
 
 
 
8126c31
e1d420c
 
 
 
 
ae74af5
06a727e
 
ae74af5
 
 
 
 
 
 
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
# ── Stage 1: build (has compiler for any source builds) ──────────
FROM python:3.11-slim AS builder

RUN apt-get update && apt-get install -y --no-install-recommends \
    libgeos-dev \
    libproj-dev \
    proj-data \
    proj-bin \
    g++ \
    && rm -rf /var/lib/apt/lists/*

# Install heavy scientific deps as binary wheels where possible
# Cartopy has no ARM wheel so it compiles from source on Mac but uses
# a pre-built wheel on HF Spaces (x86_64)
RUN pip install --no-cache-dir --only-binary :all: \
    numpy scipy matplotlib geopandas shapely pyproj rioxarray xarray \
    && pip install --no-cache-dir --prefer-binary cartopy

# Pre-download 50m Natural Earth data; non-fatal if download fails
RUN mkdir -p /root/.local/share/cartopy && \
    python -c "import cartopy.io.shapereader as s; [s.natural_earth(resolution='50m', category=c, name=n) for c, n in [('physical','land'),('physical','ocean'),('physical','coastline'),('cultural','admin_0_boundary_lines_lake')]]" \
    || echo "Natural Earth download skipped β€” Cartopy will use defaults"

# Install remaining deps (lightweight, pure-python or small wheels)
RUN pip install --no-cache-dir --prefer-binary \
    "fastapi>=0.110.0" \
    "uvicorn[standard]>=0.27.0" \
    "aiosqlite>=0.20.0" \
    "pydantic>=2.6.0" \
    "httpx>=0.27.0" \
    "pystac-client>=0.7.0" \
    "stackstac>=0.5.0" \
    "reportlab>=4.1.0" \
    "tqdm>=4.66.0" \
    "planetary-computer>=1.0.0" \
    "openeo>=0.28.0" \
    "anthropic>=0.40.0" \
    "rasterio>=1.3.0"

# ── Stage 2: runtime (no compiler, smaller image) ───────────────
FROM python:3.11-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
    libgeos-c1v5 \
    libproj25 \
    libexpat1 \
    proj-data \
    proj-bin \
    && rm -rf /var/lib/apt/lists/*

# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /root/.local/share/cartopy /root/.local/share/cartopy

WORKDIR /app

# Install app package (no-deps, just makes app/ importable)
COPY pyproject.toml .
COPY app/ app/
RUN pip install --no-cache-dir --no-deps .

COPY frontend/ frontend/

RUN mkdir -p data results

EXPOSE 7860

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]