# News keyword extraction (LLM keyword extraction into docker-job_test).
# Build from the repo root:
# docker build -f service/scripts/jobs-image/news-keywords/Dockerfile -t docker.nes.uni-due.de/inse/jobs/news-keywords:latest .
#
# Needs Elasticsearch + LLM creds (injected as env vars by the backend for
# registry images). Calls the LLM once per entry.
FROM python:3.13-slim

WORKDIR /app
ENV PYTHONUNBUFFERED=1

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

COPY background-jobs/app/ ./

# Keyword extraction contract shared with the service (inse.news.logic).
COPY service/src/main/inse/news/keyword_extraction.py ./keyword_extraction.py

# Writes into docker-job_test, leaving production aktuell_postproc untouched.
# A non-postproc target re-extracts entries that already have keywords (real
# content) and updates them in place, keyed on news_id (re-runs overwrite, no
# duplicates). Cap a run by appending --limit N via the job's command field.
ENTRYPOINT ["python", "sync.py", "--update-keywords", "--target-index", "docker-job_test"]
