[build]: add option to pull sonic-slave docker from registry (#6300)
- add config option ENABLE_DOCKER_BASE_PULL to pull sonic-slave docker from registry - use REGISTRY_PORT, REGISTRY_SERVER to specify docker registry Signed-off-by: Guohan Lu <lguohan@gmail.com>
This commit is contained in:
Родитель
d40c9a1e8d
Коммит
a79fcb49d4
|
@ -91,6 +91,10 @@ endif
|
|||
|
||||
include rules/config
|
||||
|
||||
ifeq ($(ENABLE_DOCKER_BASE_PULL),)
|
||||
override ENABLE_DOCKER_BASE_PULL = n
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIGURED_ARCH),amd64)
|
||||
SLAVE_BASE_IMAGE = $(SLAVE_DIR)
|
||||
else
|
||||
|
@ -194,6 +198,9 @@ DOCKER_BASE_BUILD = docker build --no-cache \
|
|||
--build-arg https_proxy=$(https_proxy) \
|
||||
$(SLAVE_DIR)
|
||||
|
||||
DOCKER_BASE_PULL = docker pull \
|
||||
$(REGISTRY_SERVER):$(REGISTRY_PORT)/$(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG)
|
||||
|
||||
DOCKER_BUILD = docker build --no-cache \
|
||||
--build-arg user=$(USER) \
|
||||
--build-arg uid=$(shell id -u) \
|
||||
|
@ -258,9 +265,13 @@ endif
|
|||
@pushd src/sonic-build-hooks; TRUSTED_GPG_URLS=$(TRUSTED_GPG_URLS) make all; popd
|
||||
@cp src/sonic-build-hooks/buildinfo/sonic-build-hooks* $(SLAVE_DIR)/buildinfo
|
||||
@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)
|
||||
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) ; \
|
||||
scripts/collect_docker_version_files.sh $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) target ; }
|
||||
$(DOCKER_BASE_BUILD) ; \
|
||||
scripts/collect_docker_version_files.sh $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) target ; }
|
||||
@docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \
|
||||
{ echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \
|
||||
$(DOCKER_BUILD) ; }
|
||||
|
@ -282,9 +293,13 @@ sonic-slave-base-build : sonic-build-hooks
|
|||
@$(OVERLAY_MODULE_CHECK)
|
||||
@echo Checking sonic-slave-base image: $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG)
|
||||
@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)
|
||||
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) ; \
|
||||
scripts/collect_docker_version_files.sh $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) target ; }
|
||||
$(DOCKER_BASE_BUILD) ; \
|
||||
scripts/collect_docker_version_files.sh $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) target ; }
|
||||
|
||||
sonic-slave-build : sonic-slave-base-build
|
||||
@echo Checking sonic-slave image: $(SLAVE_IMAGE):$(SLAVE_TAG)
|
||||
|
|
|
@ -179,3 +179,10 @@ TRUSTED_GPG_URLS = https://packages.trafficmanager.net/debian/public_key.gpg,htt
|
|||
# git : git repositories, donloaded by git clone
|
||||
# docker: docker base images
|
||||
SONIC_VERSION_CONTROL_COMPONENTS ?= none
|
||||
|
||||
# SONiC docker registry
|
||||
#
|
||||
# Uncomment below line to enable pulling sonic-slave docker from registry
|
||||
# ENABLE_DOCKER_BASE_PULL = y
|
||||
REGISTRY_PORT=443
|
||||
REGISTRY_SERVER=sonicdev-microsoft.azurecr.io
|
||||
|
|
Загрузка…
Ссылка в новой задаче