Skip to content

Commit 5365316

Browse files
[ci] Set default ACR in UpgrateVersion/PR/official pipeline. (sonic-net#11002)
* [ci] Set default ACR in UpgrateVersion/PR/official pipeline. (sonic-net#10341) Why I did it docker hub will limit the pull rate. Use ACR instead to pull debian related docker image. How I did it Set DEFAULT_CONTAINER_REGISTRY in pipeline. * Add a config variable to override default container registry instead of dockerhub. (sonic-net#10166) * Add variable to reset default docker registry * fix bug in docker version control
1 parent e319b98 commit 5365316

11 files changed

Lines changed: 52 additions & 17 deletions

File tree

.azure-pipelines/official-build.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,20 @@ schedules:
1818
- 201911
1919
- 201811
2020

21+
resources:
22+
repositories:
23+
- repository: buildimage
24+
type: github
25+
name: Azure/sonic-buildimage
26+
ref: master
27+
endpoint: build
28+
2129
trigger: none
2230
pr: none
2331

32+
variables:
33+
- template: .azure-pipelines/template-variables.yml@buildimage
34+
2435
stages:
2536
- stage: Build
2637
pool: sonicbld

Makefile.work

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ SLAVE_DIR = sonic-slave-stretch
7979
else
8080
SLAVE_DIR = sonic-slave-jessie
8181
endif
82-
SLAVE_BASE_TAG = $(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) j2 $(SLAVE_DIR)/Dockerfile.j2 > $(SLAVE_DIR)/Dockerfile && sha1sum $(SLAVE_DIR)/Dockerfile | awk '{print substr($$1,0,11);}')
82+
SLAVE_BASE_TAG = $(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) j2 $(SLAVE_DIR)/Dockerfile.j2 > $(SLAVE_DIR)/Dockerfile && sha1sum $(SLAVE_DIR)/Dockerfile | awk '{print substr($$1,0,11);}')
8383
SLAVE_TAG = $(shell cat $(SLAVE_DIR)/Dockerfile.user $(SLAVE_DIR)/Dockerfile | sha1sum | awk '{print substr($$1,0,11);}')
8484
SLAVE_BASE_IMAGE = $(SLAVE_DIR)
8585
SLAVE_IMAGE = $(SLAVE_BASE_IMAGE)-$(USER_LC)
@@ -109,6 +109,10 @@ DOCKER_RUN := docker run --rm=true --privileged \
109109

110110
include rules/config
111111

112+
ifneq ($(DEFAULT_CONTAINER_REGISTRY),)
113+
override DEFAULT_CONTAINER_REGISTRY := $(DEFAULT_CONTAINER_REGISTRY)/
114+
endif
115+
112116
ifeq ($(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD), y)
113117
DOCKER_RUN += -v /var/run/docker.sock:/var/run/docker.sock
114118
endif
@@ -187,6 +191,7 @@ SONIC_BUILD_INSTRUCTION := make \
187191
SONIC_INCLUDE_ACMS=$(INCLUDE_ACMS)\
188192
SONIC_INCLUDE_VNET_MONITOR=$(INCLUDE_VNET_MONITOR) \
189193
EXTRA_JESSIE_TARGETS=$(EXTRA_JESSIE_TARGETS) \
194+
DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) \
190195
$(SONIC_OVERRIDE_BUILD_VARS)
191196

192197
.PHONY: sonic-slave-build sonic-slave-bash init reset

azure-pipelines.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ resources:
3030
type: github
3131
name: Azure/sonic-mgmt
3232
endpoint: build
33+
- repository: buildimage
34+
type: github
35+
name: Azure/sonic-buildimage
36+
endpoint: build
37+
ref: master
38+
39+
variables:
40+
- template: .azure-pipelines/template-variables.yml@buildimage
3341

3442
stages:
3543
- stage: Build

dockers/docker-base-stretch/Dockerfile.j2

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
12
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
23
{% if CONFIGURED_ARCH == "armhf" %}
3-
FROM multiarch/debian-debootstrap:armhf-stretch
4+
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-stretch
45
{% elif CONFIGURED_ARCH == "arm64" %}
5-
FROM multiarch/debian-debootstrap:arm64-stretch
6+
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-stretch
67
{% else %}
7-
FROM debian:stretch
8+
FROM {{ prefix }}debian:stretch
89
{% endif %}
910

1011
# Clean documentation in FROM image

dockers/docker-base/Dockerfile.j2

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
12
{% if CONFIGURED_ARCH == "armhf" %}
2-
FROM multiarch/debian-debootstrap:armhf-jessie
3+
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-jessie
34
{% elif CONFIGURED_ARCH == "arm64" %}
4-
FROM multiarch/debian-debootstrap:arm64-jessie
5+
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-jessie
56
{% else %}
6-
FROM debian:jessie
7+
FROM {{ prefix }}/debian:jessie
78
{% endif %}
89

910
## Remove retired jessie-updates repo

dockers/docker-ptf/Dockerfile.j2

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
12
{% if CONFIGURED_ARCH == "armhf" %}
2-
FROM multiarch/debian-debootstrap:armhf-stretch
3+
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-stretch
34
{% elif CONFIGURED_ARCH == "arm64" %}
4-
FROM multiarch/debian-debootstrap:arm64-stretch
5+
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-stretch
56
{% else %}
6-
FROM debian:stretch
7+
FROM {{ prefix }}debian:stretch
78
{% endif %}
89

910
MAINTAINER Pavel Shirshov

dockers/docker-sonic-mgmt/Dockerfile.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM ubuntu:16.04
1+
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
2+
FROM {{ prefix }}ubuntu:16.04
23

34
ENV DEBIAN_FRONTEND=noninteractive
45

rules/config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,6 @@ INCLUDE_ACMS = y
129129
# INCLUDE_VNET_MONITOR - build docker-vnet-monitor for vnetping utility on the device
130130
INCLUDE_VNET_MONITOR = n
131131

132+
# reset default container registry from dockerhub to other
133+
DEFAULT_CONTAINER_REGISTRY ?=
134+

slave.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ list :
8585
###############################################################################
8686

8787
include $(RULES_PATH)/config
88+
export DEFAULT_CONTAINER_REGISTRY
8889

8990
ifeq ($(SONIC_ENABLE_PFCWD_ON_START),y)
9091
ENABLE_PFCWD_ON_START = y
@@ -223,6 +224,7 @@ $(info "INCLUDE_RESTAPI" : "$(INCLUDE_RESTAPI)")
223224
$(info "INCLUDE_SFLOW" : "$(INCLUDE_SFLOW)")
224225
$(info "INCLUDE_NAT" : "$(INCLUDE_NAT)")
225226
$(info "INCLUDE_KUBERNETES" : "$(INCLUDE_KUBERNETES)")
227+
$(info "DEFAULT_CONTAINER_REGISTRY" : "$(DEFAULT_CONTAINER_REGISTRY)")
226228
$(info )
227229

228230
ifeq ($(SONIC_USE_DOCKER_BUILDKIT),y)

sonic-slave-jessie/Dockerfile.j2

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
{% set prefix = DEFAULT_CONTAINER_REGISTRY %}
12
{%- if CONFIGURED_ARCH == "armhf" -%}
2-
FROM multiarch/debian-debootstrap:armhf-jessie
3+
FROM {{ prefix }}multiarch/debian-debootstrap:armhf-jessie
34
{%- elif CONFIGURED_ARCH == "arm64" -%}
4-
FROM multiarch/debian-debootstrap:arm64-jessie
5+
FROM {{ prefix }}multiarch/debian-debootstrap:arm64-jessie
56
{%- else -%}
6-
FROM debian:jessie
7+
FROM {{ prefix }}debian:jessie
78
{%- endif %}
89

910
MAINTAINER johnar@microsoft.com

0 commit comments

Comments
 (0)