diff --git a/agent/worker/constants.py b/agent/worker/constants.py index 4ed4b5c..d2f5aa5 100644 --- a/agent/worker/constants.py +++ b/agent/worker/constants.py @@ -29,6 +29,7 @@ _NO_PROXY = "NO_PROXY" _PUBLIC_API_RETRY_LIMIT = "PUBLIC_API_RETRY_LIMIT" _APP_DEBUG_DOCKER_IMAGE = "APP_DEBUG_DOCKER_IMAGE" +_SLY_APPS_DOCKER_REGISTRY = "SLY_APPS_DOCKER_REGISTRY" _REQUESTS_CA_BUNDLE = "REQUESTS_CA_BUNDLE" _REQUESTS_CA_BUNDLE_DIR_CONTAINER = "REQUESTS_CA_BUNDLE_DIR_CONTAINER" @@ -100,6 +101,7 @@ _GIT_PASSWORD: None, _GITHUB_TOKEN: None, _APP_DEBUG_DOCKER_IMAGE: None, + _SLY_APPS_DOCKER_REGISTRY: None, _REQUESTS_CA_BUNDLE: None, _SSL_CERT_FILE: None, _HOST_REQUESTS_CA_BUNDLE: None, @@ -526,6 +528,10 @@ def SECURITY_OPT(): return None +def SLY_APPS_DOCKER_REGISTRY(): + return read_optional_setting(_SLY_APPS_DOCKER_REGISTRY) + + def init_constants(): sly.fs.mkdir(AGENT_LOG_DIR()) sly.fs.mkdir(AGENT_TASKS_DIR()) diff --git a/agent/worker/task_app.py b/agent/worker/task_app.py index 9b419bf..7d0d685 100644 --- a/agent/worker/task_app.py +++ b/agent/worker/task_app.py @@ -266,6 +266,14 @@ def read_dockerimage_from_config(self): ) ) self.info["docker_image"] = constants.APP_DEBUG_DOCKER_IMAGE() + if constants.SLY_APPS_DOCKER_REGISTRY() is not None: + self.logger.info( + "NON DEFAULT DOCKER REGISTRY: docker image {!r} is replaced to {!r}".format( + self.info["docker_image"], f"{constants.SLY_APPS_DOCKER_REGISTRY()}/{self.info['docker_image']}" + ) + ) + self.info["docker_image"] = f"{constants.SLY_APPS_DOCKER_REGISTRY()}/{self.info['docker_image']}" + except KeyError as e: requirements_path = self.get_requirements_path() version = "latest"