Support pulling sonic-slave-docker image from path at REGISTRY_SERVER (#14907)

- Why I did it
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:

<REGISTRY_SERVER>:<REGISTRY_PORT>/<SLAVE_BASE_IMAGE>:<SLAVE_BASE_TAG>

In case the SLAVE_BASE_IMAGE appear in internal path inside the server, the convention should be like that:

<REGISTRY_SERVER>:<REGISTRY_PORT><REGISTRY_SERVER_PATH>/<SLAVE_BASE_IMAGE>:<SLAVE_BASE_TAG>

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.

- 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.
This commit is contained in:
Dror Prital 2023-05-04 11:41:10 +03:00 committed by mssonicbld
parent e2876b0062
commit 2e8b7d2ede
2 changed files with 3 additions and 2 deletions

View File

@ -403,7 +403,7 @@ DOCKER_SLAVE_BASE_BUILD = docker build --no-cache \
$(SPLIT_LOG) $(DOCKER_BASE_LOG) $(SPLIT_LOG) $(DOCKER_BASE_LOG)
DOCKER_BASE_PULL = docker pull \ 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_USER_BUILD = docker build --no-cache \ DOCKER_USER_BUILD = docker build --no-cache \
--build-arg user=$(USER) \ --build-arg user=$(USER) \
@ -429,7 +429,7 @@ DOCKER_SLAVE_BASE_PULL_REGISTRY = \
$(DOCKER_BASE_PULL); \ $(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) && \
$(COLLECT_DOCKER); \ $(COLLECT_DOCKER); \
}\ }\

View File

@ -254,6 +254,7 @@ MIRROR_SNAPSHOT ?= n
# Set the env variable ENABLE_DOCKER_BASE_PULL = y to enable pulling sonic-slave docker from registry # Set the env variable ENABLE_DOCKER_BASE_PULL = y to enable pulling sonic-slave docker from registry
REGISTRY_PORT ?= 443 REGISTRY_PORT ?= 443
REGISTRY_SERVER ?= sonicdev-microsoft.azurecr.io 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 - if set to y multi-asic KVM images will be generated.
BUILD_MULTIASIC_KVM = n BUILD_MULTIASIC_KVM = n