graf-model / Dockerfile
hprmn's picture
update streamlit app
14f0b4c
FROM python:3.9-slim
WORKDIR /app
# Install system dependencies including geospatial libraries
RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
gcc \
g++ \
libgdal-dev \
gdal-bin \
libgeos-dev \
libproj-dev \
libspatialindex-dev \
&& rm -rf /var/lib/apt/lists/*
# Set GDAL environment variables
ENV GDAL_CONFIG=/usr/bin/gdal-config
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
ENV C_INCLUDE_PATH=/usr/include/gdal
# Create writable directories for Streamlit and other components
RUN mkdir -p /tmp/.streamlit /tmp/.matplotlib /tmp/.config /tmp/.cache /tmp/.local && \
chmod -R 777 /tmp
# Set environment variables BEFORE copying requirements
ENV HOME=/tmp
ENV MPLCONFIGDIR=/tmp/.matplotlib
ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
ENV XDG_CONFIG_HOME=/tmp/.config
ENV XDG_CACHE_HOME=/tmp/.cache
# Copy requirements and install Python dependencies
COPY requirements.txt ./
RUN pip3 install --no-cache-dir --upgrade pip && \
pip3 install --no-cache-dir -r requirements.txt
# Copy application files
COPY src/ ./src/
COPY .streamlit/ /tmp/.streamlit/
# Expose port (HF Spaces uses 7860 by default, but keeping 8501 as per template)
EXPOSE 8501
# Health check with updated URL
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
# Updated entrypoint with XSRF protection disabled for HF Spaces
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", \
"--server.port=8501", \
"--server.address=0.0.0.0", \
"--server.headless=true", \
"--server.enableXsrfProtection=false", \
"--server.enableCORS=false", \
"--server.fileWatcherType=none"]