# Projekt-Topic-Mapping (bund keywords -> OpenAlex topics). Build from the repo root:
# docker build -f service/scripts/jobs-image/project-topics/Dockerfile -t docker.nes.uni-due.de/inse/jobs/project-topics:latest .
#
# Needs a reachable backend (vector search) and Elasticsearch creds. The creds
# arrive as env vars injected by the backend for registry images.
FROM python:3.13-slim

WORKDIR /app
ENV PYTHONUNBUFFERED=1

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

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

# Writes topic mappings into docker-job_test. Only maps (project, keyword) pairs
# not already present in the output index, so an interrupted run can be resumed.
# There is no overwrite flag: to re-map all, point --output-index at a fresh index.
# 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.projects.topic_mapper.map_project_topics", \
    "--source-index", "projects_bund_v1", \
    "--text-field", "Leistungsplansystematik_fullname", \
    "--output-index", "docker-job_test", \
    "--api-base-url", "http://host.docker.internal:8000"]
