Skip to content

Commit

Permalink
[ci] Set default ACR in UpgrateVersion/PR/official pipeline. (sonic-n…
Browse files Browse the repository at this point in the history
…et#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
  • Loading branch information
liushilongbuaa committed Jul 12, 2022
1 parent e319b98 commit 5365316
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 17 deletions.
11 changes: 11 additions & 0 deletions .azure-pipelines/official-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,20 @@ schedules:
- 201911
- 201811

resources:
repositories:
- repository: buildimage
type: github
name: Azure/sonic-buildimage
ref: master
endpoint: build

trigger: none
pr: none

variables:
- template: .azure-pipelines/template-variables.yml@buildimage

stages:
- stage: Build
pool: sonicbld
Expand Down
7 changes: 6 additions & 1 deletion Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ SLAVE_DIR = sonic-slave-stretch
else
SLAVE_DIR = sonic-slave-jessie
endif
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);}')
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);}')
SLAVE_TAG = $(shell cat $(SLAVE_DIR)/Dockerfile.user $(SLAVE_DIR)/Dockerfile | sha1sum | awk '{print substr($$1,0,11);}')
SLAVE_BASE_IMAGE = $(SLAVE_DIR)
SLAVE_IMAGE = $(SLAVE_BASE_IMAGE)-$(USER_LC)
Expand Down 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 @@ -187,6 +191,7 @@ SONIC_BUILD_INSTRUCTION := make \
SONIC_INCLUDE_ACMS=$(INCLUDE_ACMS)\
SONIC_INCLUDE_VNET_MONITOR=$(INCLUDE_VNET_MONITOR) \
EXTRA_JESSIE_TARGETS=$(EXTRA_JESSIE_TARGETS) \
DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) \
$(SONIC_OVERRIDE_BUILD_VARS)

.PHONY: sonic-slave-build sonic-slave-bash init reset
Expand Down
8 changes: 8 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ resources:
type: github
name: Azure/sonic-mgmt
endpoint: build
- repository: buildimage
type: github
name: Azure/sonic-buildimage
endpoint: build
ref: master

variables:
- template: .azure-pipelines/template-variables.yml@buildimage

stages:
- stage: Build
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:stretch
{% 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 @@ -129,3 +129,6 @@ INCLUDE_ACMS = y
# INCLUDE_VNET_MONITOR - build docker-vnet-monitor for vnetping utility on the device
INCLUDE_VNET_MONITOR = n

# 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 @@ -223,6 +224,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" : "$(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 5365316

Please sign in to comment.