# HG changeset patch
# User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr>
# Date 1698762707 -3600
#      Tue Oct 31 15:31:47 2023 +0100
# Node ID c747e0fbe9973287f67670d23035df8e4e605208
# Parent  9316d43827ec1c5920b2b2bac155b279d159bdd3
docker_build: Use Orus API token in PIP_INDEX_URL

diff --git a/NEWS.rst b/NEWS.rst
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,6 +2,11 @@
 History
 =======
 
+20.14.0
+-------
+
+docker_build: Use the Orus API token if available (giving it to docker in the environment variable PIP_INDEX_URL)
+
 20.13.0
 -------
 
diff --git a/odoo_scripts/docker_build.py b/odoo_scripts/docker_build.py
--- a/odoo_scripts/docker_build.py
+++ b/odoo_scripts/docker_build.py
@@ -17,6 +17,7 @@
 from .docker_build_copy import add_build_copy_options, copy, get_build_copy_options
 from .docker_client import DockerClient
 from .parsing import apply, basic_parser
+from .storage import get_orus_api_token
 
 _logger = logging.getLogger(__name__)
 
@@ -177,6 +178,15 @@
             a = arg.split("=")
             buildargs[a[0]] = a[1]
     _logger.debug("Build args: %s", buildargs)
+    if nmspc.orus_api_token or get_orus_api_token():
+        buildargs[
+            "PIP_INDEX_URL"
+        ] = f"https://__token__:{nmspc.orus_api_token or get_orus_api_token()}@orus.io/api/v4/groups/9/-/packages/pypi/simple"  # noqa: E501
+    else:
+        if c.orus_api_token_required:
+            _logger.error(
+                "No Orus API token provided, the project indicates it is mandatory"
+            )
     if dev:
         debug_dockerfile = "Dockerfile.debug"
         call(["cp", dockerfile, debug_dockerfile])