# News-Topic-Mapping (news keywords -> OpenAlex topics). Build from the repo root:
# docker build -f service/scripts/jobs-image/news-topics/Dockerfile -t docker.nes.uni-due.de/inse/jobs/news-topics:latest .
#
# map_news_topics imports map_project_topics as its "base", so both topic_mapper
# packages must be present. Needs a reachable backend and Elasticsearch creds
# (injected as env vars by the backend for registry images).
FROM python:3.13-slim

WORKDIR /app
ENV PYTHONUNBUFFERED=1

COPY service/scripts/jobs-image/news-topics/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY service/scripts/news/topic_mapper/ ./service/scripts/news/topic_mapper/
COPY service/scripts/projects/topic_mapper/ ./service/scripts/projects/topic_mapper/

# Writes topic mappings into aktuell_openalex_topics. Only maps (article, keyword)
# pairs not already present in the output index; pass --overwrite to re-map all.
# Uncapped: limit a run by passing --max-docs N through the job's command field.
# host.docker.internal reaches the host backend for vector search.
ENTRYPOINT ["python", "-m", "service.scripts.news.topic_mapper.map_news_topics", \
    "--output-index", "aktuell_openalex_topics", \
    "--api-base-url", "http://host.docker.internal:8000"]
