diff --git a/.gitignore b/.gitignore index 2a2d70646c..7e2f73f718 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ target/ # Autogenerated Dockerfiles sonic-slave*/Dockerfile +sonic-slave*/Dockerfile.user dockers/*/Dockerfile platform/*/docker-*/Dockerfile diff --git a/Makefile.cache b/Makefile.cache index cce4dedb69..4037222ffc 100644 --- a/Makefile.cache +++ b/Makefile.cache @@ -72,9 +72,9 @@ SONIC_COMMON_FLAGS_LIST := $(CONFIGURED_PLATFORM) \ $(SONIC_PROFILING_ON) $(SONIC_ENABLE_SYNCD_RPC) SONIC_COMMON_DPKG_LIST := debian/control debian/changelog debian/rules \ debian/compat debian/install debian/copyright -SONIC_COMMON_BASE_FILES_LIST := sonic-slave-jessie/Dockerfile.j2 sonic-slave-jessie/Dockerfile.user \ - sonic-slave-stretch/Dockerfile.j2 sonic-slave-stretch/Dockerfile.user \ - sonic-slave-buster/Dockerfile.j2 sonic-slave-buster/Dockerfile.user +SONIC_COMMON_BASE_FILES_LIST := sonic-slave-jessie/Dockerfile.j2 sonic-slave-jessie/Dockerfile.user.j2 \ + sonic-slave-stretch/Dockerfile.j2 sonic-slave-stretch/Dockerfile.user.j2 \ + sonic-slave-buster/Dockerfile.j2 sonic-slave-buster/Dockerfile.user.j2 @@ -181,7 +181,7 @@ define GET_MOD_DEP_SHA $($(dfile)_DEP_FLAGS_FILE) $($(dfile)_MOD_HASH_FILE) $($(dfile)_SMOD_HASH_FILE)) ) $(eval $(1)_DEP_FILES_MISSING := $(filter-out $(wildcard $($(1)_DEP_MOD_SHA_FILES)),$($(1)_DEP_MOD_SHA_FILES)) ) $(if $($(1)_DEP_FILES_MISSING), $(warning "[ DPKG ] Dependecy file(s) are not found for $(1) : $($(1)_DEP_FILES_MISSING))) - + $(eval $(1)_DEP_MOD_SHA := $(shell git hash-object $($(1)_DEP_MOD_SHA_FILES) \ | sha1sum | awk '{print substr($$1,0,23);}')) endef diff --git a/Makefile.work b/Makefile.work index 021f9e0c13..ef9b5570ac 100644 --- a/Makefile.work +++ b/Makefile.work @@ -91,7 +91,11 @@ endif include rules/config +ifeq ($(CONFIGURED_ARCH),amd64) SLAVE_BASE_IMAGE = $(SLAVE_DIR) +else +SLAVE_BASE_IMAGE = $(SLAVE_DIR)-$(CONFIGURED_ARCH) +endif SLAVE_IMAGE = $(SLAVE_BASE_IMAGE)-$(USER) # Generate the version control build info @@ -101,6 +105,7 @@ $(shell SONIC_VERSION_CONTROL_COMPONENTS=$(SONIC_VERSION_CONTROL_COMPONENTS) \ # Generate the slave Dockerfile, and prepare build info for it $(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) j2 $(SLAVE_DIR)/Dockerfile.j2 > $(SLAVE_DIR)/Dockerfile) +$(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) 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)) # Add the versions in the tag, if the version change, need to rebuild the slave diff --git a/sonic-slave-buster/Dockerfile.user b/sonic-slave-buster/Dockerfile.user.j2 similarity index 83% rename from sonic-slave-buster/Dockerfile.user rename to sonic-slave-buster/Dockerfile.user.j2 index e292a8a677..a1181524bd 100644 --- a/sonic-slave-buster/Dockerfile.user +++ b/sonic-slave-buster/Dockerfile.user.j2 @@ -1,5 +1,9 @@ ARG slave_base_tag_ref=latest +{%- if CONFIGURED_ARCH == "amd64" %} FROM sonic-slave-buster:${slave_base_tag_ref} +{%- else %} +FROM sonic-slave-buster-{{ CONFIGURED_ARCH }}:${slave_base_tag_ref} +{%- endif %} # Add user ARG user diff --git a/sonic-slave-jessie/Dockerfile.user b/sonic-slave-jessie/Dockerfile.user.j2 similarity index 83% rename from sonic-slave-jessie/Dockerfile.user rename to sonic-slave-jessie/Dockerfile.user.j2 index 37dd7256c4..4f9ed9da65 100644 --- a/sonic-slave-jessie/Dockerfile.user +++ b/sonic-slave-jessie/Dockerfile.user.j2 @@ -1,5 +1,9 @@ ARG slave_base_tag_ref=latest +{%- if CONFIGURED_ARCH == "amd64" %} FROM sonic-slave-jessie:${slave_base_tag_ref} +{%- else %} +FROM sonic-slave-jessie-{{ CONFIGURED_ARCH }}:${slave_base_tag_ref} +{%- endif %} # Add user ARG user diff --git a/sonic-slave-stretch/Dockerfile.user b/sonic-slave-stretch/Dockerfile.user.j2 similarity index 83% rename from sonic-slave-stretch/Dockerfile.user rename to sonic-slave-stretch/Dockerfile.user.j2 index 87e4d9568b..8e94b7046a 100644 --- a/sonic-slave-stretch/Dockerfile.user +++ b/sonic-slave-stretch/Dockerfile.user.j2 @@ -1,5 +1,9 @@ ARG slave_base_tag_ref=latest +{%- if CONFIGURED_ARCH == "amd64" %} FROM sonic-slave-stretch:${slave_base_tag_ref} +{%- else %} +FROM sonic-slave-stretch-{{ CONFIGURED_ARCH }}:${slave_base_tag_ref} +{%- endif %} # Add user ARG user