build-unit-test-docker: provide docker registry override
docker.io continues to tighten control[1] on access to its registry.
Provide a mechanism within this script to utilize a different registry
for the base ubuntu image.
[1]: https://www.docker.com/blog/november-2024-updated-plans-announcement/
Tested:
- Confirmed script default still works as expected
- Confirmed the following also works now:
export DOCKER_REG=public.ecr.aws/ubuntu
Change-Id: I4e8251653003cfac514905f2d2a5e8787b8ec06a
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/scripts/build-unit-test-docker b/scripts/build-unit-test-docker
index a25f747..d4af404 100755
--- a/scripts/build-unit-test-docker
+++ b/scripts/build-unit-test-docker
@@ -17,6 +17,9 @@
# UBUNTU_MIRROR: <optional, the URL of a mirror of Ubuntu to override the
# default ones in /etc/apt/sources.list>
# default is empty, and no mirror is used.
+# DOCKER_REG: <optional, the URL of a docker registry to utilize
+# instead of the default docker hub
+# (ex. public.ecr.aws/ubuntu)
# http_proxy The HTTP address of the proxy server to connect to.
# Default: "", proxy is not setup if this is not set
@@ -700,6 +703,7 @@
distro = os.environ.get("DISTRO", "ubuntu:noble")
branch = os.environ.get("BRANCH", "master")
ubuntu_mirror = os.environ.get("UBUNTU_MIRROR")
+docker_reg = os.environ.get("DOCKER_REG", "docker.io")
http_proxy = os.environ.get("http_proxy")
gerrit_project = os.environ.get("GERRIT_PROJECT")
@@ -765,7 +769,7 @@
# Create base Dockerfile.
dockerfile_base = f"""
-FROM {distro}
+FROM {docker_reg}/{distro}
{mirror}