diff --git a/service/src/main/inse/background_jobs/runner.py b/service/src/main/inse/background_jobs/runner.py index e05af513..beb20ccd 100644 --- a/service/src/main/inse/background_jobs/runner.py +++ b/service/src/main/inse/background_jobs/runner.py @@ -75,9 +75,21 @@ def resolve_environment(definition: JobDefinition) -> dict[str, str]: return {**base, **(definition.env or {})} +def registry_auth() -> Optional[dict[str, str]]: + if ( + settings.background_jobs_registry_username + and settings.background_jobs_registry_password + ): + return { + "username": settings.background_jobs_registry_username, + "password": settings.background_jobs_registry_password, + } + return None + + def pull_image(image: str) -> None: try: - get_docker_client().images.pull(image) + get_docker_client().images.pull(image, auth_config=registry_auth()) logger.info("Pulled image '%s' from the registry.", image) except Exception: logger.warning( diff --git a/service/src/main/inse/config.py b/service/src/main/inse/config.py index e85488dd..aebc16c6 100644 --- a/service/src/main/inse/config.py +++ b/service/src/main/inse/config.py @@ -55,6 +55,11 @@ class Settings(BaseSettings): # (e.g. :latest) is picked up. Disable for local image development, where # a locally built image would otherwise be overwritten by the registry. background_jobs_pull_before_run: bool = True + # Credentials for pulling the job image from a private registry (e.g. the + # Nexus at docker.nes.uni-due.de). Needed because the runner pulls via the + # Docker SDK inside the service container, which has no `docker login` creds. + background_jobs_registry_username: Optional[str] = None + background_jobs_registry_password: Optional[str] = None # Sentence Transformers config sentence_transformers_model_name: str = "intfloat/multilingual-e5-base"