From 5f3269a61b7fd5c69309af89e5ea6dcfa9642c2d Mon Sep 17 00:00:00 2001 From: Saikrishna Arcot Date: Wed, 24 Nov 2021 17:00:14 -0800 Subject: [PATCH] Create a docker-swss-layer that holds the swss package. This is to save about 40MB of disk space, since 5 containers individually install this package. Signed-off-by: Saikrishna Arcot (cherry picked from commit bd479cad296f435814305b63af5545416a7d1934) --- dockers/docker-fpm-frr/Dockerfile.j2 | 2 +- dockers/docker-nat/Dockerfile.j2 | 2 +- dockers/docker-orchagent/Dockerfile.j2 | 2 +- dockers/docker-sflow/Dockerfile.j2 | 2 +- .../docker-swss-layer-buster/Dockerfile.j2 | 22 +++++++++++++++++++ dockers/docker-teamd/Dockerfile.j2 | 2 +- rules/docker-fpm-frr.mk | 6 ++--- rules/docker-nat.mk | 6 ++--- rules/docker-orchagent.mk | 6 ++--- rules/docker-sflow.mk | 6 ++--- rules/docker-swss-layer-buster.dep | 10 +++++++++ rules/docker-swss-layer-buster.mk | 14 ++++++++++++ rules/docker-teamd.mk | 6 ++--- 13 files changed, 66 insertions(+), 20 deletions(-) create mode 100644 dockers/docker-swss-layer-buster/Dockerfile.j2 create mode 100644 rules/docker-swss-layer-buster.dep create mode 100644 rules/docker-swss-layer-buster.mk diff --git a/dockers/docker-fpm-frr/Dockerfile.j2 b/dockers/docker-fpm-frr/Dockerfile.j2 index 42df1c6f38..f392d4d3a7 100644 --- a/dockers/docker-fpm-frr/Dockerfile.j2 +++ b/dockers/docker-fpm-frr/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster +FROM docker-swss-layer-buster ARG docker_container_name ARG frr_user_uid diff --git a/dockers/docker-nat/Dockerfile.j2 b/dockers/docker-nat/Dockerfile.j2 index 36a178a68a..066de0a70e 100644 --- a/dockers/docker-nat/Dockerfile.j2 +++ b/dockers/docker-nat/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, copy_files %} -FROM docker-config-engine-buster +FROM docker-swss-layer-buster ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf diff --git a/dockers/docker-orchagent/Dockerfile.j2 b/dockers/docker-orchagent/Dockerfile.j2 index 41425c4d9b..70dc98c34c 100755 --- a/dockers/docker-orchagent/Dockerfile.j2 +++ b/dockers/docker-orchagent/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster +FROM docker-swss-layer-buster ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf diff --git a/dockers/docker-sflow/Dockerfile.j2 b/dockers/docker-sflow/Dockerfile.j2 index 476ff3514a..c8d0757d5f 100644 --- a/dockers/docker-sflow/Dockerfile.j2 +++ b/dockers/docker-sflow/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster +FROM docker-swss-layer-buster ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf diff --git a/dockers/docker-swss-layer-buster/Dockerfile.j2 b/dockers/docker-swss-layer-buster/Dockerfile.j2 new file mode 100644 index 0000000000..e8dcb9472a --- /dev/null +++ b/dockers/docker-swss-layer-buster/Dockerfile.j2 @@ -0,0 +1,22 @@ +{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} +FROM docker-config-engine-buster + +## Make apt-get non-interactive +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update + +{% if docker_swss_layer_buster_debs.strip() -%} +# Copy locally-built Debian package dependencies +{{ copy_files("debs/", docker_swss_layer_buster_debs.split(' '), "/debs/") }} + +# Install locally-built Debian packages and implicitly install their dependencies +{{ install_debian_packages(docker_swss_layer_buster_debs.split(' ')) }} +{%- endif %} + +RUN apt-get clean -y && \ + apt-get autoclean -y && \ + apt-get autoremove -y && \ + rm -rf /debs + +ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/dockers/docker-teamd/Dockerfile.j2 b/dockers/docker-teamd/Dockerfile.j2 index 7f4db29368..e02000abb1 100644 --- a/dockers/docker-teamd/Dockerfile.j2 +++ b/dockers/docker-teamd/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster +FROM docker-swss-layer-buster ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf diff --git a/rules/docker-fpm-frr.mk b/rules/docker-fpm-frr.mk index dca3f30ad5..171623dd3e 100644 --- a/rules/docker-fpm-frr.mk +++ b/rules/docker-fpm-frr.mk @@ -8,13 +8,13 @@ $(DOCKER_FPM_FRR)_PATH = $(DOCKERS_PATH)/$(DOCKER_FPM_FRR_STEM) $(DOCKER_FPM_FRR)_PYTHON_WHEELS += $(SONIC_BGPCFGD) $(SONIC_FRR_MGMT_FRAMEWORK) $(DOCKER_FPM_FRR)_DEPENDS += $(FRR) $(FRR_SNMP) $(SWSS) $(LIBYANG1) -$(DOCKER_FPM_FRR)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_FPM_FRR)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS) $(DOCKER_FPM_FRR)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) \ $(FRR_DBG) $(FRR_SNMP_DBG) $(LIBYANG1_DBG) -$(DOCKER_FPM_FRR)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_FPM_FRR)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES) -$(DOCKER_FPM_FRR)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_FPM_FRR)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) SONIC_DOCKER_IMAGES += $(DOCKER_FPM_FRR) diff --git a/rules/docker-nat.mk b/rules/docker-nat.mk index 981019dbcd..ef58241a13 100644 --- a/rules/docker-nat.mk +++ b/rules/docker-nat.mk @@ -7,11 +7,11 @@ DOCKER_NAT_DBG = $(DOCKER_NAT_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_NAT)_PATH = $(DOCKERS_PATH)/$(DOCKER_NAT_STEM) $(DOCKER_NAT)_DEPENDS += $(SWSS) $(IPTABLESIP4TC) $(IPTABLESIP6TC) $(IPTABLESIPTC) $(IPXTABLES12) $(IPTABLES) -$(DOCKER_NAT)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_NAT)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS) $(DOCKER_NAT)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) -$(DOCKER_NAT)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_NAT)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES) -$(DOCKER_NAT)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_NAT)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) ifeq ($(INCLUDE_NAT), y) SONIC_DOCKER_IMAGES += $(DOCKER_NAT) diff --git a/rules/docker-orchagent.mk b/rules/docker-orchagent.mk index 78cef9fd1a..a5e5823957 100644 --- a/rules/docker-orchagent.mk +++ b/rules/docker-orchagent.mk @@ -6,16 +6,16 @@ DOCKER_ORCHAGENT_DBG = $(DOCKER_ORCHAGENT_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_ORCHAGENT)_DEPENDS += $(SWSS) -$(DOCKER_ORCHAGENT)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_ORCHAGENT)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS) $(DOCKER_ORCHAGENT)_DBG_DEPENDS += $(SWSS_DBG) \ $(LIBSWSSCOMMON_DBG) \ $(LIBSAIREDIS_DBG) -$(DOCKER_ORCHAGENT)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_ORCHAGENT)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES) $(DOCKER_ORCHAGENT)_PATH = $(DOCKERS_PATH)/$(DOCKER_ORCHAGENT_STEM) -$(DOCKER_ORCHAGENT)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_ORCHAGENT)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) SONIC_DOCKER_IMAGES += $(DOCKER_ORCHAGENT) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ORCHAGENT) diff --git a/rules/docker-sflow.mk b/rules/docker-sflow.mk index f9386190a4..d6d898b252 100644 --- a/rules/docker-sflow.mk +++ b/rules/docker-sflow.mk @@ -7,11 +7,11 @@ DOCKER_SFLOW_DBG = $(DOCKER_SFLOW_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_SFLOW)_PATH = $(DOCKERS_PATH)/$(DOCKER_SFLOW_STEM) $(DOCKER_SFLOW)_DEPENDS += $(SWSS) $(HSFLOWD) $(SFLOWTOOL) $(PSAMPLE) -$(DOCKER_SFLOW)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_SFLOW)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS) $(DOCKER_TEAMD)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) -$(DOCKER_SFLOW)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_SFLOW)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES) -$(DOCKER_SFLOW)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_SFLOW)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) SONIC_DOCKER_IMAGES += $(DOCKER_SFLOW) ifeq ($(INCLUDE_SFLOW), y) diff --git a/rules/docker-swss-layer-buster.dep b/rules/docker-swss-layer-buster.dep new file mode 100644 index 0000000000..d245a29269 --- /dev/null +++ b/rules/docker-swss-layer-buster.dep @@ -0,0 +1,10 @@ + +DPATH := $($(DOCKER_SWSS_LAYER_BUSTER)_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-swss-layer-buster.mk rules/docker-swss-layer-buster.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files $(DPATH)) + +$(DOCKER_SWSS_LAYER_BUSTER)_CACHE_MODE := GIT_CONTENT_SHA +$(DOCKER_SWSS_LAYER_BUSTER)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(DOCKER_SWSS_LAYER_BUSTER)_DEP_FILES := $(DEP_FILES) + diff --git a/rules/docker-swss-layer-buster.mk b/rules/docker-swss-layer-buster.mk new file mode 100644 index 0000000000..f04a09fbca --- /dev/null +++ b/rules/docker-swss-layer-buster.mk @@ -0,0 +1,14 @@ +# docker image for sonic swss layer + +DOCKER_SWSS_LAYER_BUSTER = docker-swss-layer-buster.gz +$(DOCKER_SWSS_LAYER_BUSTER)_PATH = $(DOCKERS_PATH)/docker-swss-layer-buster + +$(DOCKER_SWSS_LAYER_BUSTER)_DEPENDS += $(SWSS) +$(DOCKER_SWSS_LAYER_BUSTER)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) + +$(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) \ + $(SWSS) +$(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) + +SONIC_DOCKER_IMAGES += $(DOCKER_SWSS_LAYER_BUSTER) +SONIC_BUSTER_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) diff --git a/rules/docker-teamd.mk b/rules/docker-teamd.mk index c0fe6bfb6b..ad89b57137 100644 --- a/rules/docker-teamd.mk +++ b/rules/docker-teamd.mk @@ -7,13 +7,13 @@ DOCKER_TEAMD_DBG = $(DOCKER_TEAMD_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_TEAMD)_PATH = $(DOCKERS_PATH)/$(DOCKER_TEAMD_STEM) $(DOCKER_TEAMD)_DEPENDS += $(SWSS) $(LIBTEAMDCTL) $(LIBTEAM_UTILS) -$(DOCKER_TEAMD)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_TEAMD)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS) $(DOCKER_TEAMD)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) $(DOCKER_TEAMD)_DBG_DEPENDS += $(LIBTEAMDCTL_DBG) $(LIBTEAM_UTILS_DBG) -$(DOCKER_TEAMD)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_TEAMD)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES) -$(DOCKER_TEAMD)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_TEAMD)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) SONIC_DOCKER_IMAGES += $(DOCKER_TEAMD) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_TEAMD)