From e9a2e1b6a5cf68968d05d2fbf07334e2b0c9c850 Mon Sep 17 00:00:00 2001 From: Dror Prital <76714716+dprital@users.noreply.github.com> Date: Wed, 10 May 2023 20:56:12 +0300 Subject: [PATCH] Add ability to navigate to specific path inside registry server (#14946) Why I did it Backport PR #14907 to 202205 branch In order to reduce sonic build time, there is an option to acquire sonic slave docker(s) from artifact server (reduce sonic make configure time). Current implementation supports only convention of: :/: In case the SLAVE_BASE_IMAGE appear in internal path inside the server, the convention should be like that: :/: When REGISTRY_SERVER_PATH (that is set on rules/config) will have to start with "/". If REGISTRY_SERVER_PATH will not be set, the behavior will remain the same it works today. Work item tracking Microsoft ADO (number only): How I did it Add ability to set REGISTRY_SERVER_PATH and update the code for docker image tag and docker image pull accordingly How to verify it Use sonic slave docker image from artifact server in which the image is kept in internal folder and make sure it consume it. --- Makefile.work | 6 +++--- rules/config | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile.work b/Makefile.work index 3737c47e84..facb17222c 100644 --- a/Makefile.work +++ b/Makefile.work @@ -330,7 +330,7 @@ DOCKER_BASE_BUILD = docker build --no-cache \ $(SLAVE_DIR) $(SPLIT_LOG) $(DOCKER_BASE_LOG) DOCKER_BASE_PULL = docker pull \ - $(REGISTRY_SERVER):$(REGISTRY_PORT)/$(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) + $(REGISTRY_SERVER):$(REGISTRY_PORT)$(REGISTRY_SERVER_PATH)/$(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) DOCKER_BUILD = docker build --no-cache \ --build-arg user=$(USER) \ @@ -431,7 +431,7 @@ endif @docker inspect --type image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) &> /dev/null || \ { [ $(ENABLE_DOCKER_BASE_PULL) == y ] && { echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Pulling...; } && \ $(DOCKER_BASE_PULL) && \ - { docker tag $(REGISTRY_SERVER):$(REGISTRY_PORT)/$(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) && \ + { docker tag $(REGISTRY_SERVER):$(REGISTRY_PORT)$(REGISTRY_SERVER_PATH)/$(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) && \ scripts/collect_docker_version_files.sh $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) target ; } } || \ { echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Building... ; \ $(DOCKER_BASE_BUILD) ; \ @@ -466,7 +466,7 @@ endif @docker inspect --type image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) &> /dev/null || \ { [ $(ENABLE_DOCKER_BASE_PULL) == y ] && { echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Pulling...; } && \ $(DOCKER_BASE_PULL) && \ - { docker tag $(REGISTRY_SERVER):$(REGISTRY_PORT)/$(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) && \ + { docker tag $(REGISTRY_SERVER):$(REGISTRY_PORT)$(REGISTRY_SERVER_PATH)/$(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) && \ scripts/collect_docker_version_files.sh $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) target ; } } || \ { echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Building... ; \ $(DOCKER_BASE_BUILD) ; \ diff --git a/rules/config b/rules/config index 9b9ab10251..ef70bddee3 100644 --- a/rules/config +++ b/rules/config @@ -233,6 +233,7 @@ MIRROR_SNAPSHOT ?= n # Set the env variable ENABLE_DOCKER_BASE_PULL = y to enable pulling sonic-slave docker from registry REGISTRY_PORT ?= 443 REGISTRY_SERVER ?= sonicdev-microsoft.azurecr.io +REGISTRY_SERVER_PATH ?= # BUILD_MULTIASIC_KVM - if set to y multi-asic KVM images will be generated. BUILD_MULTIASIC_KVM = n