FROM python:3.12-slim

WORKDIR /app

# ffmpeg for potential thumbnail generation; build tools needed by some
# reverse_geocoder wheels.
RUN apt-get update && apt-get install -y --no-install-recommends \
        ffmpeg \
    && rm -rf /var/lib/apt/lists/*

COPY server/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy server application code
COPY server/app.py .
COPY server/modules/ ./modules/
COPY server/scripts/ ./scripts/
COPY server/templates/ ./templates/
COPY server/sql/ ./sql/

# Copy shared frontend assets (Bootstrap, Leaflet, fonts, CSS, JS)
COPY static/ ./static/

EXPOSE 8098

# gunicorn instead of the Flask dev server for production use; single worker
# is enough for this low-traffic single-device use case, threaded to allow
# concurrent tracking + dashcam-upload requests.
CMD ["gunicorn", "--bind", "0.0.0.0:8098", "--workers", "1", "--threads", "4", \
     "--timeout", "300", "app:app"]
