File size: 1,727 Bytes
6de9ffb
 
 
 
14f0b4c
6de9ffb
 
 
 
 
14f0b4c
 
 
 
 
 
 
6de9ffb
 
14f0b4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6de9ffb
14f0b4c
 
6de9ffb
14f0b4c
 
 
6de9ffb
14f0b4c
6de9ffb
 
14f0b4c
6de9ffb
 
14f0b4c
 
 
 
 
 
 
 
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
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"]