Change in docker-playground[master]: common: Automatize UPSTREAM_DISTRO name based on image name

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Dec 1 11:46:20 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/docker-playground/+/21238 )

Change subject: common: Automatize UPSTREAM_DISTRO name based on image name
......................................................................

common: Automatize UPSTREAM_DISTRO name based on image name

Similar to what is already done with DISTRO, which points to given image
of ours based on name. This time we do the same with upstream images,
such as debian:stretch or centos:centos8.

This way, for instance calling docker_images_require
"osmo-bsc-latest-centos8" would try to build the
osmo-bsc-latest/Dockerfile file starting from a centos8 image.

Change-Id: I33cb21aa024396974559fd98f9f3c64e2c351eda
---
M centos-repo-install-test/Dockerfile
M centos8-build/Dockerfile
M debian-repo-install-test/Dockerfile
M debian-stretch-build/Dockerfile
M debian-stretch-titan/Dockerfile
M jenkins-common.sh
M make/Makefile
M osmo-bsc-latest/Dockerfile
M osmo-bts-latest/Dockerfile
M osmo-cn-latest/Dockerfile
M osmo-ggsn-latest/Dockerfile
M osmo-hlr-latest/Dockerfile
M osmo-hnbgw-latest/Dockerfile
M osmo-mgw-latest/Dockerfile
M osmo-msc-latest/Dockerfile
M osmo-nitb-latest/Dockerfile
M osmo-pcu-latest/Dockerfile
M osmo-remsim-latest/Dockerfile
M osmo-sgsn-latest/Dockerfile
M osmo-sip-latest/Dockerfile
M osmo-stp-latest/Dockerfile
21 files changed, 61 insertions(+), 26 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  daniel: Looks good to me, but someone else must approve
  pespin: Verified



diff --git a/centos-repo-install-test/Dockerfile b/centos-repo-install-test/Dockerfile
index 3f53650..5cbddb0 100644
--- a/centos-repo-install-test/Dockerfile
+++ b/centos-repo-install-test/Dockerfile
@@ -1,6 +1,7 @@
 ARG	USER
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/centos:centos8
+ARG	UPSTREAM_DISTRO=centos:centos8
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 # dnf-utils: for repoquery
 RUN	dnf install -y \
@@ -9,4 +10,3 @@
 
 # Make additional development libraries available
 RUN	yum config-manager --set-enabled PowerTools
-
diff --git a/centos8-build/Dockerfile b/centos8-build/Dockerfile
index 46ce23e..e71e03c 100644
--- a/centos8-build/Dockerfile
+++ b/centos8-build/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/centos:centos8
+ARG	UPSTREAM_DISTRO=centos:centos8
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 # Let package metadata expire after 60 seconds instead of 48 hours
 RUN	echo "metadata_expire=60" >> /etc/dnf/dnf.conf && cat /etc/dnf/dnf.conf
diff --git a/debian-repo-install-test/Dockerfile b/debian-repo-install-test/Dockerfile
index e718a23..e12da75 100644
--- a/debian-repo-install-test/Dockerfile
+++ b/debian-repo-install-test/Dockerfile
@@ -1,6 +1,7 @@
 ARG	USER
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 COPY	Release.key /tmp/Release.key
 
diff --git a/debian-stretch-build/Dockerfile b/debian-stretch-build/Dockerfile
index ac52708..96e92de 100644
--- a/debian-stretch-build/Dockerfile
+++ b/debian-stretch-build/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/debian-stretch-titan/Dockerfile b/debian-stretch-titan/Dockerfile
index 7420348..01d941e 100644
--- a/debian-stretch-titan/Dockerfile
+++ b/debian-stretch-titan/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/jenkins-common.sh b/jenkins-common.sh
index d9e79a4..fdcfd40 100644
--- a/jenkins-common.sh
+++ b/jenkins-common.sh
@@ -12,10 +12,18 @@
 
 docker_distro_from_image_name() {
 	case "$1" in
-	osmo-*-centos8) echo "centos8"; ;;
+	osmo-*-centos8) echo "centos8" ;;
+	centos8-*) echo "centos8" ;;
 	*) echo "debian-stretch" ;;
 	esac
+}
 
+docker_upstream_distro_from_image_name() {
+	case "$1" in
+	osmo-*-centos8) echo "centos:centos8"; ;;
+	centos8-*) echo "centos:centos8" ;;
+	*) echo "debian:stretch" ;;
+	esac
 }
 
 docker_dir_from_image_name() {
@@ -27,15 +35,20 @@
 
 # Make sure required images are available and build them if necessary.
 # $*: image names (e.g. "debian-stretch-build", "osmo-mgw-master", "osmo-mgw-master-centos8")
-#	The images are automatically built from the Dockerfile of the subdir of the same name. If there is a
-#	distribution name at the end of the image name (e.g. osmo-mgw-master-centos8), it gets removed from the subdir
-#	where the Dockerfile is taken from (e.g. osmo-mgw-master/Dockerfile) and DISTRO is passed accordingly
-#	(e.g. DISTRO=centos8). This allows one Dockerfile for multiple distributions, without duplicating configs for
-#	each distribution. Dependencies listed in docker_depends() are built automatically too.
+#	The images are automatically built from the Dockerfile of the subdir of
+#	the same name. If there is a distribution name at the end of the image
+#	name (e.g. osmo-mgw-master-centos8), it gets removed from the subdir
+#	where the Dockerfile is taken from (e.g. osmo-mgw-master/Dockerfile)
+#	and UPSTREAM_DISTRO and DISTRO are passed accordingly (e.g.
+#	UPSTREAM_DISTRO=centos:centos8 DISTRO=centos8). This allows one
+#	Dockerfile for multiple distributions, without duplicating configs for
+#	each distribution. Dependencies listed in docker_depends() are built
+#	automatically too.
 docker_images_require() {
 	local i
 	local from_line
 	local pull_arg
+	local upstream_distro_arg
 	local distro_arg
 	local depends
 	local dir
@@ -49,6 +62,7 @@
 
 		# Trigger image build (cache will be used when up-to-date)
 		if [ -z "$NO_DOCKER_IMAGE_BUILD" ]; then
+			upstream_distro_arg="$(docker_upstream_distro_from_image_name "$i")"
 			distro_arg="$(docker_distro_from_image_name "$i")"
 			dir="$(docker_dir_from_image_name "$i")"
 
@@ -62,6 +76,7 @@
 			echo "Building image: $i (export NO_DOCKER_IMAGE_BUILD=1 to prevent this)"
 			make -C "../$dir" \
 				PULL="$pull_arg" \
+				UPSTREAM_DISTRO="$upstream_distro_arg" \
 				DISTRO="$distro_arg" \
 				IMAGE="$REPO_USER/$i" \
 				|| exit 1
diff --git a/make/Makefile b/make/Makefile
index 1a13c4d..63562f3 100644
--- a/make/Makefile
+++ b/make/Makefile
@@ -33,6 +33,7 @@
 OSMO_SIP_BRANCH?=master
 OSMO_STP_BRANCH?=master
 PULL?=
+UPSTREAM_DISTRO?=debian:stretch
 DISTRO?=debian-stretch
 
 RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-release-support
@@ -61,6 +62,7 @@
 		--build-arg USER=$(USERNAME) \
 		--build-arg REGISTRY=$(REGISTRY_HOST) \
 		--build-arg OSMO_TTCN3_BRANCH=$(OSMO_TTCN3_BRANCH) \
+		--build-arg UPSTREAM_DISTRO=$(UPSTREAM_DISTRO) \
 		--build-arg DISTRO=$(DISTRO) \
 		--build-arg LIBOSMOCORE_BRANCH=$(LIBOSMOCORE_BRANCH) \
 		--build-arg OSMO_BB_BRANCH=$(OSMO_BB_BRANCH) \
diff --git a/osmo-bsc-latest/Dockerfile b/osmo-bsc-latest/Dockerfile
index 1ab1e02..178af72 100644
--- a/osmo-bsc-latest/Dockerfile
+++ b/osmo-bsc-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-bts-latest/Dockerfile b/osmo-bts-latest/Dockerfile
index df1d832..954fc58 100644
--- a/osmo-bts-latest/Dockerfile
+++ b/osmo-bts-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-cn-latest/Dockerfile b/osmo-cn-latest/Dockerfile
index ba98621..ca6859d 100644
--- a/osmo-cn-latest/Dockerfile
+++ b/osmo-cn-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Daniel Willmann <dwillmann at sysmocom.de>
 
diff --git a/osmo-ggsn-latest/Dockerfile b/osmo-ggsn-latest/Dockerfile
index ac50c4e..3430791 100644
--- a/osmo-ggsn-latest/Dockerfile
+++ b/osmo-ggsn-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-hlr-latest/Dockerfile b/osmo-hlr-latest/Dockerfile
index 606a2df..a8e106c 100644
--- a/osmo-hlr-latest/Dockerfile
+++ b/osmo-hlr-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-hnbgw-latest/Dockerfile b/osmo-hnbgw-latest/Dockerfile
index 15e515f..b39d2e7 100644
--- a/osmo-hnbgw-latest/Dockerfile
+++ b/osmo-hnbgw-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-mgw-latest/Dockerfile b/osmo-mgw-latest/Dockerfile
index eba9ace..27fb259 100644
--- a/osmo-mgw-latest/Dockerfile
+++ b/osmo-mgw-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-msc-latest/Dockerfile b/osmo-msc-latest/Dockerfile
index 6fc5858..e52a79a 100644
--- a/osmo-msc-latest/Dockerfile
+++ b/osmo-msc-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-nitb-latest/Dockerfile b/osmo-nitb-latest/Dockerfile
index 5dafc33..ccdb75a 100644
--- a/osmo-nitb-latest/Dockerfile
+++ b/osmo-nitb-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-pcu-latest/Dockerfile b/osmo-pcu-latest/Dockerfile
index ccd492c..ad5187e 100644
--- a/osmo-pcu-latest/Dockerfile
+++ b/osmo-pcu-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-remsim-latest/Dockerfile b/osmo-remsim-latest/Dockerfile
index 2229032..fdc41ee 100644
--- a/osmo-remsim-latest/Dockerfile
+++ b/osmo-remsim-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-sgsn-latest/Dockerfile b/osmo-sgsn-latest/Dockerfile
index f24b11c..23a06a1 100644
--- a/osmo-sgsn-latest/Dockerfile
+++ b/osmo-sgsn-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-sip-latest/Dockerfile b/osmo-sip-latest/Dockerfile
index cdf1315..a310ecd 100644
--- a/osmo-sip-latest/Dockerfile
+++ b/osmo-sip-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 
diff --git a/osmo-stp-latest/Dockerfile b/osmo-stp-latest/Dockerfile
index aca833f..6651c44 100644
--- a/osmo-stp-latest/Dockerfile
+++ b/osmo-stp-latest/Dockerfile
@@ -1,5 +1,6 @@
 ARG	REGISTRY=docker.io
-FROM	${REGISTRY}/debian:stretch
+ARG	UPSTREAM_DISTRO=debian:stretch
+FROM	${REGISTRY}/${UPSTREAM_DISTRO}
 
 MAINTAINER Harald Welte <laforge at gnumonks.org>
 

-- 
To view, visit https://gerrit.osmocom.org/c/docker-playground/+/21238
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: I33cb21aa024396974559fd98f9f3c64e2c351eda
Gerrit-Change-Number: 21238
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201201/715ccb94/attachment.htm>


More information about the gerrit-log mailing list