[cpp-linbuild] 21/25: Build Docker sub-image for each component/platform combination

Scott Cantor cantor.2 at osu.edu
Mon Apr 5 12:47:04 UTC 2021


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository cpp-linbuild.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-linbuild.git;a=commit;h=2d272c5ed4434eb473a48cd20487a2aeb31e9ec4

commit 2d272c5ed4434eb473a48cd20487a2aeb31e9ec4
Author: John W. O'Brien <john at saltant.com>
AuthorDate: Sun Feb 28 22:13:41 2021 +0000

    Build Docker sub-image for each component/platform combination
---
 Makefile                         | 22 +++++++++++++++++++---
 os/.gitignore                    |  1 +
 os/amazonlinux2/image/Dockerfile |  2 --
 os/centos6/image/Dockerfile      |  2 --
 os/centos7/image/Dockerfile      |  2 --
 os/centos8/image/Dockerfile      |  2 --
 6 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index a34ed65..c66690d 100644
--- a/Makefile
+++ b/Makefile
@@ -191,16 +191,33 @@ $(foreach platform,$(PLATFORMS),$(eval $(call build-docker-image-platform,$(plat
 .PHONY: images
 images: $(foreach platform,$(PLATFORMS),$(platform)-image)
 
+# Build a docker image for each component/platform combination
+define build-docker-image-component-platform
+$(srcdir)os/$(2)/image/Dockerfile.$$($(1)_COMPNAME):
+	echo "FROM shibboleth/$(2):$$(BASETAG)" > $$@
+	echo "COPY build-$($(1)_COMPNAME).sh \$$$${BUILD_BASE}/" >> $$@
+
+$(1)_$(2)_image_token = $$(srcdir).$(1)_$(2)_image
+$$($(1)_$(2)_image_token): $$($(2)_token) $(srcdir)os/$(2)/image/Dockerfile.$$($(1)_COMPNAME) $(srcdir)os/$(2)/image/build-$$($(1)_COMPNAME).sh
+	docker build -t shibboleth/$(2):$($(1)_COMPNAME) \
+		-f os/$(2)/image/Dockerfile.$$($(1)_COMPNAME) \
+		os/$(2)/image
+	touch $$($(1)_$(2)_image_token)
+$$($(1)_COMPNAME)-$(2)-image: $$($(1)_$(2)_image_token)
+endef
+
+$(foreach platform,$(PLATFORMS),$(foreach component,$(COMPONENTS),$(eval $(call build-docker-image-component-platform,$(component),$(platform)))))
+
 
 # Build RPMs and SRPMs for a each component on each platform
 define build-component-platform
 $(1)_$(2)_token = $(srcdir).$(1)_$(2)_products
-$$($(1)_$(2)_token): $$($(2)_token) $(SOURCEDIR)/$$($(1)_DISTFILE) $(SPECDIR)/$$($(1)_COMPNAME).spec
+$$($(1)_$(2)_token): $$($(1)_$(2)_image_token) $(SOURCEDIR)/$$($(1)_DISTFILE) $(SPECDIR)/$$($(1)_COMPNAME).spec
 	mkdir -p $(srcdir)os/$(2)/products/{RPMS,SRPMS}
 	docker run -it --rm \
 		--mount type=bind,source=$(srcdir)os/$(2)/products,target=/opt/build/external/out \
 		--mount type=bind,source=$(srcdir)common,target=/opt/build/external/in \
-		shibboleth/$(2):$(BASETAG) \
+		shibboleth/$(2):$($(1)_COMPNAME) \
 		/bin/sh /opt/build/build-$($(1)_COMPNAME).sh
 	touch $$($(1)_$(2)_token)
 $$($(1)_COMPNAME)_$(2): $$($(1)_$(2)_token)
@@ -211,7 +228,6 @@ $(foreach platform,$(PLATFORMS),$(foreach component,$(COMPONENTS),$(eval $(call
 # TODO:
 #  delete stale products on version bump
 #  add a clean target
-#  teach each image to depend on the build scripts for that image
 #  refresh an affected image in the event one of its dependencies changes
 #  save build logs to the host
 #  auto-generate build-scripts (maybe)
diff --git a/os/.gitignore b/os/.gitignore
index abb4e77..fbc4f00 100644
--- a/os/.gitignore
+++ b/os/.gitignore
@@ -1 +1,2 @@
 */products
+Dockerfile.*
diff --git a/os/amazonlinux2/image/Dockerfile b/os/amazonlinux2/image/Dockerfile
index 10901f1..ef9bb93 100644
--- a/os/amazonlinux2/image/Dockerfile
+++ b/os/amazonlinux2/image/Dockerfile
@@ -29,6 +29,4 @@ RUN echo "%_rpmdir ${EXT_BASE}/out/RPMS" >> ~/.rpmmacros
 RUN echo "%_srcrpmdir ${EXT_BASE}/out/SRPMS" >> ~/.rpmmacros
 RUN echo "%packager PLACE HOLDER <USER at EXAMPLE.COM>" >> ~/.rpmmacros
 
-COPY . ${BUILD_BASE}
-
 WORKDIR ${EXT_BASE}/in/SPECS
diff --git a/os/centos6/image/Dockerfile b/os/centos6/image/Dockerfile
index 0dc71dd..c685ad7 100644
--- a/os/centos6/image/Dockerfile
+++ b/os/centos6/image/Dockerfile
@@ -29,6 +29,4 @@ RUN echo "%_rpmdir ${EXT_BASE}/out/RPMS" >> ~/.rpmmacros
 RUN echo "%_srcrpmdir ${EXT_BASE}/out/SRPMS" >> ~/.rpmmacros
 RUN echo "%packager PLACE HOLDER <USER at EXAMPLE.COM>" >> ~/.rpmmacros
 
-COPY *.sh ${BUILD_BASE}/
-
 WORKDIR ${EXT_BASE}/in/SPECS
diff --git a/os/centos7/image/Dockerfile b/os/centos7/image/Dockerfile
index 4be0c3d..d8a6a0b 100644
--- a/os/centos7/image/Dockerfile
+++ b/os/centos7/image/Dockerfile
@@ -27,6 +27,4 @@ RUN echo "%_rpmdir ${EXT_BASE}/out/RPMS" >> ~/.rpmmacros
 RUN echo "%_srcrpmdir ${EXT_BASE}/out/SRPMS" >> ~/.rpmmacros
 RUN echo "%packager PLACE HOLDER <USER at EXAMPLE.COM>" >> ~/.rpmmacros
 
-COPY . ${BUILD_BASE}
-
 WORKDIR ${EXT_BASE}/in/SPECS
diff --git a/os/centos8/image/Dockerfile b/os/centos8/image/Dockerfile
index 30f6af2..9908380 100644
--- a/os/centos8/image/Dockerfile
+++ b/os/centos8/image/Dockerfile
@@ -29,6 +29,4 @@ RUN echo "%_rpmdir ${EXT_BASE}/out/RPMS" >> ~/.rpmmacros
 RUN echo "%_srcrpmdir ${EXT_BASE}/out/SRPMS" >> ~/.rpmmacros
 RUN echo "%packager PLACE HOLDER <USER at EXAMPLE.COM>" >> ~/.rpmmacros
 
-COPY . ${BUILD_BASE}
-
 WORKDIR ${EXT_BASE}/in/SPECS

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list