File size: 1,484 Bytes
cfea739
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c110c9c
 
 
6258aac
cfea739
 
 
 
 
 
 
66a90a7
6258aac
 
66a90a7
cfea739
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c110c9c
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
# Use Python 3.11 slim image for better compatibility with scientific packages
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Install system dependencies required for the scientific packages
RUN apt-get update && apt-get install -y \
    build-essential \
    libproj-dev \
    proj-data \
    proj-bin \
    libgeos-dev \
    libgdal-dev \
    gdal-bin \
    libspatialindex-dev \
    libffi-dev \
    git \
    git-lfs \
    curl \
    wget \
    chromium \
    && rm -rf /var/lib/apt/lists/*

# Set environment variables for GDAL
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
ENV C_INCLUDE_PATH=/usr/include/gdal
ENV GDAL_DATA=/usr/share/gdal

# Set environment variable for Chromium (needed by Kaleido)
ENV CHROME_BIN=/usr/bin/chromium
ENV CHROME_PATH=/usr/bin/chromium

# Copy requirements first for better caching
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application code
COPY . .

# Create necessary directories
RUN mkdir -p uploads downloads/extracted plots shapefiles static templates

# Set environment variables for Flask
ENV FLASK_APP=app.py
ENV FLASK_ENV=production
ENV PYTHONUNBUFFERED=1

# Expose the port that Hugging Face Spaces expects
EXPOSE 7860

# Create a non-root user for security
RUN useradd -m -u 1000 user && chown -R user:user /app
USER user

# Command to run the application
# Note: Hugging Face Spaces expects the app to run on port 7860
CMD ["python", "startup.py"]