Spaces:
Sleeping
Sleeping
| # 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"] |