[jenkins-ci PATCH v2 9/9] docker: add a makefile for building docker images locally

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a simple makefile that can generate dockerfiles and run local builds
of them.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 .gitignore           |  1 +
 dockerfiles/Makefile | 33 +++++++++++++++++++++++++++++++++
 guests/lcitool       | 15 +++++++++++++--
 3 files changed, 47 insertions(+), 2 deletions(-)
 create mode 100644 dockerfiles/Makefile

diff --git a/.gitignore b/.gitignore
index b25c15b..c92cb0e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 *~
+dockerfiles/*.docker
diff --git a/dockerfiles/Makefile b/dockerfiles/Makefile
new file mode 100644
index 0000000..0075840
--- /dev/null
+++ b/dockerfiles/Makefile
@@ -0,0 +1,33 @@
+
+LCITOOL = ../guests/lcitool
+
+HOSTS = $(shell $(LCITOOL) -a hosts)
+
+CROSS_HOST = libvirt-debian-9
+
+ARCHES = $(shell $(LCITOOL) -a arches -h $(CROSS_HOST))
+
+CONFIGS = $(wildcard ../guests/host_vars/*/docker.yml)
+
+DOCKERFILES = $(shell $(LCITOOL) -a dockerfiles)
+
+DOCKERIMAGES = $(DOCKERFILES:%.docker=%)
+
+all: $(DOCKERFILES)
+
+buildenv-%.docker: $(LCITOOL) $(CONFIGS)
+	case $@ in  \
+	    *cross*) \
+	        HOST=`echo $@ | sed -e 's/-cross-.*//' -e 's/buildenv-//' -e 's/.docker//'` && \
+	        ARCH=`echo $@ | sed -e 's/^.*-cross-//' -e 's/.docker//'` && \
+	        $(LCITOOL) -a dockerfile -p libvirt -h $$HOST -x $$ARCH > $@ ;; \
+	    *) \
+	        HOST=`echo $@ | sed -e 's/buildenv-//' -e 's/.docker//'` && \
+	        $(LCITOOL) -a dockerfile -p libvirt -h $$HOST > $@ ;; \
+	esac
+
+buildenv-%: buildenv-%.docker
+	docker build --tag $@ -f $< .
+
+clean:
+	rm -f *.docker *~
diff --git a/guests/lcitool b/guests/lcitool
index dc5741e..a5ae817 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -313,8 +313,9 @@ class Application:
                   build    build projects on hosts
 
                 informational actions:
-                  hosts     list all known hosts
-                  projects  list all known projects
+                  hosts        list all known hosts
+                  projects     list all known projects
+                  dockerfiles  list all known dockerfiles
 
                 uncommon actions:
                   dockerfile  generate Dockerfile (doesn't access the host)
@@ -415,6 +416,16 @@ class Application:
         for project in self._projects.expand_pattern("all"):
             print(project)
 
+    def _action_dockerfiles(self, _hosts, _projects, _revision, _cross_arch):
+        for host in self._inventory.expand_pattern("all"):
+            facts = self._inventory.get_facts(host)
+            package_format = facts["package_format"]
+            if package_format not in ["deb", "rpm"]:
+                continue
+            print ("buildenv-%s.docker" % host)
+            for arch in facts.get("cross_build", {}).get("arches", {}).keys():
+                print ("buildenv-%s-cross-%s.docker" % (host, arch))
+
     def _action_install(self, hosts, _projects, _revision, _cross_arch):
         base = Util.get_base()
 
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux