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"]