Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a config variable to override default container registry instead of dockerhub. #10166

Merged
merged 5 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ rules/config.user:
include rules/config
-include rules/config.user

ifneq ($(DEFAULT_CONTAINER_REGISTRY),)
override DEFAULT_CONTAINER_REGISTRY := $(DEFAULT_CONTAINER_REGISTRY)/
endif

ifeq ($(ENABLE_DOCKER_BASE_PULL),)
override ENABLE_DOCKER_BASE_PULL = n
endif
Expand All @@ -139,9 +143,9 @@ $(shell SONIC_VERSION_CONTROL_COMPONENTS=$(SONIC_VERSION_CONTROL_COMPONENTS) \
scripts/generate_buildinfo_config.sh)

# Generate the slave Dockerfile, and prepare build info for it
$(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) DOCKER_EXTRA_OPTS=$(DOCKER_EXTRA_OPTS) j2 $(SLAVE_DIR)/Dockerfile.j2 > $(SLAVE_DIR)/Dockerfile)
$(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) DOCKER_EXTRA_OPTS=$(DOCKER_EXTRA_OPTS) DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) j2 $(SLAVE_DIR)/Dockerfile.j2 > $(SLAVE_DIR)/Dockerfile)
$(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) j2 $(SLAVE_DIR)/Dockerfile.user.j2 > $(SLAVE_DIR)/Dockerfile.user)
$(shell BUILD_SLAVE=y scripts/prepare_docker_buildinfo.sh $(SLAVE_BASE_IMAGE) $(SLAVE_DIR)/Dockerfile $(CONFIGURED_ARCH) "" $(BLDENV))
$(shell BUILD_SLAVE=y DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) scripts/prepare_docker_buildinfo.sh $(SLAVE_BASE_IMAGE) $(SLAVE_DIR)/Dockerfile $(CONFIGURED_ARCH) "" $(BLDENV))

# Add the versions in the tag, if the version change, need to rebuild the slave
SLAVE_BASE_TAG = $(shell cat $(SLAVE_DIR)/Dockerfile $(SLAVE_DIR)/buildinfo/versions/versions-* src/sonic-build-hooks/hooks/* | sha1sum | awk '{print substr($$1,0,11);}')
Expand Down Expand Up @@ -291,6 +295,7 @@ SONIC_BUILD_INSTRUCTION := make \
EXTRA_DOCKER_TARGETS=$(EXTRA_DOCKER_TARGETS) \
BUILD_LOG_TIMESTAMP=$(BUILD_LOG_TIMESTAMP) \
SONIC_ENABLE_IMAGE_SIGNATURE=$(ENABLE_IMAGE_SIGNATURE) \
SONIC_DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) \
ENABLE_HOST_SERVICE_ON_START=$(ENABLE_HOST_SERVICE_ON_START) \
SLAVE_DIR=$(SLAVE_DIR) \
ENABLE_AUTO_TECH_SUPPORT=$(ENABLE_AUTO_TECH_SUPPORT) \
Expand Down
7 changes: 4 additions & 3 deletions dockers/docker-base-bullseye/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
{% if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:armhf-bullseye
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-bullseye
{% elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:arm64-bullseye
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-bullseye
{% else %}
FROM {{DOCKER_BASE_ARCH}}/debian:bullseye
FROM {{ prefix }}{{DOCKER_BASE_ARCH}}/debian:bullseye
{% endif %}

# Clean documentation in FROM image
Expand Down
7 changes: 4 additions & 3 deletions dockers/docker-base-buster/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
{% if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:armhf-buster
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-buster
{% elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:arm64-buster
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-buster
{% else %}
FROM {{DOCKER_BASE_ARCH}}/debian:buster
FROM {{ prefix }}{{DOCKER_BASE_ARCH}}/debian:buster
{% endif %}

# Clean documentation in FROM image
Expand Down
7 changes: 4 additions & 3 deletions dockers/docker-base-stretch/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
{% if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:armhf-stretch
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-stretch
{% elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:arm64-stretch
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-stretch
{% else %}
FROM {{DOCKER_BASE_ARCH}}/debian:stretch
FROM {{ prefix }}{{DOCKER_BASE_ARCH}}/debian:stretch
{% endif %}

# Clean documentation in FROM image
Expand Down
7 changes: 4 additions & 3 deletions dockers/docker-base/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
{% if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:armhf-jessie
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-jessie
{% elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:arm64-jessie
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-jessie
{% else %}
FROM {{DOCKER_BASE_ARCH}}/debian:jessie
FROM {{ prefix }}{{DOCKER_BASE_ARCH}}/debian:jessie
{% endif %}

## Remove retired jessie-updates repo
Expand Down
7 changes: 4 additions & 3 deletions dockers/docker-ptf/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
{% if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:armhf-stretch
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-stretch
{% elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:arm64-stretch
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-stretch
{% else %}
FROM debian:buster
FROM {{ prefix }}debian:buster
{% endif %}

MAINTAINER Pavel Shirshov
Expand Down
3 changes: 2 additions & 1 deletion dockers/docker-sonic-mgmt/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ubuntu:18.04
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
FROM {{ prefix }}ubuntu:18.04

ENV DEBIAN_FRONTEND=noninteractive

Expand Down
3 changes: 3 additions & 0 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,6 @@ INCLUDE_MUX = y

# ENABLE_ASAN - enable address sanitizer
ENABLE_ASAN ?= n

# reset default container registry from dockerhub to other
DEFAULT_CONTAINER_REGISTRY ?=
6 changes: 4 additions & 2 deletions scripts/docker_version_control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ mkdir -p target/versions/default
. src/sonic-build-hooks/buildinfo/config/buildinfo.config

image_tag=`grep "^FROM " $DOCKERFILE | awk '{print$2}'`
image_tag_noprefix=$image_tag
[ -n "$DEFAULT_CONTAINER_REGISTRY" ] && image_tag_noprefix=$(echo $image_tag | sed "s#$DEFAULT_CONTAINER_REGISTRY##")
image=`echo $image_tag | cut -f1 -d:`
tag=`echo $image_tag | cut -f2 -d:`

Expand All @@ -25,7 +27,7 @@ if [[ ",$SONIC_VERSION_CONTROL_COMPONENTS," == *,all,* ]] || [[ ",$SONIC_VERSION
exit 0
fi
if [ -f $version_file ];then
hash_value=`grep "${ARCH}:${image_tag}" $version_file | awk -F== '{print$2}'`
hash_value=`grep "${ARCH}:${image_tag_noprefix}" $version_file | awk -F== '{print$2}'`
fi
if [ -z $hash_value ];then
hash_value=unknown
Expand All @@ -43,5 +45,5 @@ else
fi
fi
if [[ "$hash_value" != "unknown" ]];then
echo -e "${ARCH}:${image_tag}==$hash_value" >> $new_version_file
echo -e "${ARCH}:${image_tag_noprefix}==$hash_value" >> $new_version_file
fi
3 changes: 3 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ include $(RULES_PATH)/config
export PACKAGE_URL_PREFIX
export TRUSTED_GPG_URLS
export SONIC_VERSION_CONTROL_COMPONENTS
DEFAULT_CONTAINER_REGISTRY := $(SONIC_DEFAULT_CONTAINER_REGISTRY)
export DEFAULT_CONTAINER_REGISTRY

ifeq ($(SONIC_ENABLE_PFCWD_ON_START),y)
ENABLE_PFCWD_ON_START = y
Expand Down Expand Up @@ -326,6 +328,7 @@ $(info "PDDF_SUPPORT" : "$(PDDF_SUPPORT)")
$(info "MULTIARCH_QEMU_ENVIRON" : "$(MULTIARCH_QEMU_ENVIRON)")
$(info "SONIC_VERSION_CONTROL_COMPONENTS": "$(SONIC_VERSION_CONTROL_COMPONENTS)")
$(info "ENABLE_ASAN" : "$(ENABLE_ASAN)")
$(info "DEFAULT_CONTAINER_REGISTRY" : "$(SONIC_DEFAULT_CONTAINER_REGISTRY)")
ifeq ($(CONFIGURED_PLATFORM),vs)
$(info "BUILD_MULTIASIC_KVM" : "$(BUILD_MULTIASIC_KVM)")
endif
Expand Down
11 changes: 6 additions & 5 deletions sonic-slave-bullseye/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
{%- if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/qemu-user-static:x86_64-arm-6.1.0-8 as qemu
FROM multiarch/debian-debootstrap:armhf-bullseye
FROM {{ prefix }}multiarch/qemu-user-static:x86_64-arm-6.1.0-8 as qemu
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-bullseye
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
{%- elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/qemu-user-static:x86_64-aarch64-6.1.0-8 as qemu
FROM multiarch/debian-debootstrap:arm64-bullseye
FROM {{ prefix }}multiarch/qemu-user-static:x86_64-aarch64-6.1.0-8 as qemu
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-bullseye
COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin
{%- else -%}
FROM debian:bullseye
FROM {{ prefix }}debian:bullseye
{%- endif %}

MAINTAINER gulv@microsoft.com
Expand Down
9 changes: 5 additions & 4 deletions sonic-slave-buster/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
{%- if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/qemu-user-static:x86_64-arm-5.0.0-2 as qemu
FROM multiarch/debian-debootstrap:armhf-buster
FROM {{ prefix }}multiarch/qemu-user-static:x86_64-arm-5.0.0-2 as qemu
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-buster
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
{%- elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:arm64-buster
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-buster
{%- else -%}
FROM debian:buster
FROM {{ prefix }}debian:buster
{%- endif %}

MAINTAINER gulv@microsoft.com
Expand Down
7 changes: 4 additions & 3 deletions sonic-slave-jessie/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
{%- if CONFIGURED_ARCH == "armhf" -%}
FROM multiarch/debian-debootstrap:armhf-jessie
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-jessie
{%- elif CONFIGURED_ARCH == "arm64" -%}
FROM multiarch/debian-debootstrap:arm64-jessie
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-jessie
{%- else -%}
FROM debian:jessie
FROM {{ prefix }}debian:jessie
{%- endif %}

MAINTAINER johnar@microsoft.com
Expand Down
7 changes: 4 additions & 3 deletions sonic-slave-stretch/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
{%- if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:armhf-stretch
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-stretch
{%- elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %}
FROM multiarch/debian-debootstrap:arm64-stretch
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-stretch
{%- else -%}
FROM debian:stretch
FROM {{ prefix }}debian:stretch
{%- endif %}

MAINTAINER gulv@microsoft.com
Expand Down