| # Use official Python 3.9 slim image as base | |
| FROM python:3.9-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| sqlite3 \ | |
| supervisor \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements file | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application files | |
| COPY frontend.py . | |
| COPY backend.py . | |
| COPY init_db.py . | |
| COPY static/ static/ | |
| COPY supervisord.conf . | |
| # Create logs directory and set permissions | |
| RUN mkdir -p /app/logs && chmod -R 777 /app/logs | |
| # Initialize SQLite database and set permissions | |
| RUN python init_db.py && chmod 666 /app/crime_records.db | |
| # Expose port 8501 for Streamlit (Hugging Face Spaces default) | |
| EXPOSE 8501 | |
| # Run supervisord to manage Flask and Streamlit | |
| CMD ["supervisord", "-c", "supervisord.conf"] |