Skip to content

Commit

Permalink
Add a config variable to override default container registry instead …
Browse files Browse the repository at this point in the history
…of dockerhub. (sonic-net#10166)

* Add variable to reset default docker registry
* fix bug in docker version control
  • Loading branch information
liushilongbuaa committed Jun 13, 2022
1 parent 4c4fa0d commit 963ec79
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 16 deletions.
5 changes: 5 additions & 0 deletions Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ DOCKER_RUN := docker run --rm=true --privileged \

include rules/config

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

ifeq ($(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD), y)
DOCKER_RUN += -v /var/run/docker.sock:/var/run/docker.sock
endif
Expand Down Expand Up @@ -185,6 +189,7 @@ SONIC_BUILD_INSTRUCTION := make \
SONIC_INCLUDE_SYSTEM_TELEMETRY=$(INCLUDE_SYSTEM_TELEMETRY) \
SONIC_INCLUDE_RESTAPI=$(INCLUDE_RESTAPI) \
EXTRA_JESSIE_TARGETS=$(EXTRA_JESSIE_TARGETS) \
SONIC_DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) \
$(SONIC_OVERRIDE_BUILD_VARS)

.PHONY: sonic-slave-build sonic-slave-bash init reset
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" %}
FROM multiarch/debian-debootstrap:armhf-stretch
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-stretch
{% elif CONFIGURED_ARCH == "arm64" %}
FROM multiarch/debian-debootstrap:arm64-stretch
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-stretch
{% else %}
FROM debian:stretch
FROM {{ prefix }}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" %}
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 %}

## 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" %}
FROM multiarch/debian-debootstrap:armhf-stretch
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-stretch
{% elif CONFIGURED_ARCH == "arm64" %}
FROM multiarch/debian-debootstrap:arm64-stretch
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-stretch
{% else %}
FROM debian:stretch
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:16.04
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
FROM {{ prefix }}ubuntu:16.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 @@ -125,3 +125,6 @@ KUBERNETES_VERSION = 1.18.6
KUBERNETES_CNI_VERSION = 0.8.6
K8s_GCR_IO_PAUSE_VERSION = 3.2

# reset default container registry from dockerhub to other
DEFAULT_CONTAINER_REGISTRY ?=

2 changes: 2 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ list :
###############################################################################

include $(RULES_PATH)/config
export DEFAULT_CONTAINER_REGISTRY

ifeq ($(SONIC_ENABLE_PFCWD_ON_START),y)
ENABLE_PFCWD_ON_START = y
Expand Down Expand Up @@ -213,6 +214,7 @@ $(info "INCLUDE_RESTAPI" : "$(INCLUDE_RESTAPI)")
$(info "INCLUDE_SFLOW" : "$(INCLUDE_SFLOW)")
$(info "INCLUDE_NAT" : "$(INCLUDE_NAT)")
$(info "INCLUDE_KUBERNETES" : "$(INCLUDE_KUBERNETES)")
$(info "DEFAULT_CONTAINER_REGISTRY" : "$(SONIC_DEFAULT_CONTAINER_REGISTRY)")
$(info )

ifeq ($(SONIC_USE_DOCKER_BUILDKIT),y)
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" %}
FROM multiarch/debian-debootstrap:armhf-stretch
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-stretch
{%- elif CONFIGURED_ARCH == "arm64" %}
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

0 comments on commit 963ec79

Please sign in to comment.