# One Dockerfile, two images: the build arg APP selects the entry point.
#
#   docker build --build-arg APP=manga -t .../manga-mover-and-metadata-collector .
#   docker build --build-arg APP=ln    -t .../kavita-lightnovel-metadata-fetcher .
#
# Both variants share src/; the variant-specific code lives in
# src/manga/ resp. src/ln/ and is selected by the entry point.

FROM python:3.12-slim

ARG APP=manga

WORKDIR /app

# System deps for Pillow (image dimensions, manga variant); kept minimal.
RUN apt-get update \
 && apt-get install -y --no-install-recommends \
        libjpeg62-turbo \
 && rm -rf /var/lib/apt/lists/*

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

COPY src/          /app/src/
COPY main_manga.py main_ln.py /app/

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    APP_VARIANT=${APP}

# /config is used by both variants; the manga variant additionally mounts
# /mnt/suwayomi and /mnt/kavita (see docker-compose.prod.yml).
VOLUME ["/config"]

EXPOSE 8080

CMD python /app/main_${APP_VARIANT}.py
