File size: 1,430 Bytes
475558b
 
 
 
 
 
 
 
 
 
 
 
 
0808aa3
 
 
 
 
 
 
 
 
 
475558b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c0f4d27
475558b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0808aa3
 
 
475558b
 
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
FROM python:3.10-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    wget \
    gcc \
    g++ \
    libgeos-dev \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user
RUN useradd -m -u 1000 appuser

# Create directories and set permissions
RUN mkdir -p /app/data /app/.config/matplotlib && \
    chown -R appuser:appuser /app

# Set environment variable for matplotlib
ENV MPLCONFIGDIR=/app/.config/matplotlib

# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip

# Install JAX without GPU support (for CPU-only deployment)
RUN pip install --no-cache-dir \
    "jax[cpu]" \
    jaxlib

# Install GraphCast and its dependencies
RUN pip install --no-cache-dir \
    numpy \
    matplotlib \
    xarray \
    scipy \
    dm-haiku \
    optax \
    cartopy \
    google-cloud-storage \
    ipywidgets \
    pillow \
    gradio>=4.0.0 \
    git+https://github.com/deepmind/graphcast.git

# Workaround for cartopy crashes due to the shapely installed by default
# Same as the workaround in the original notebook
RUN pip uninstall -y shapely && \
    pip install shapely --no-binary shapely

# Copy application code
COPY app.py /app/

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7860

# Expose port
EXPOSE 7860

# Switch to non-root user
USER appuser

# Set command
CMD ["python", "app.py"]