[dockerfiles PATCH 1/3] refresh: Generate archived Dockerfiles

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

 



We need this so that we can perform Quay builds without going
through a build trigger.

Once we start generating Dockerfiles this way, each refresh will
result in a bunch of binary files being modified, which is not
very nice to humans following along at home.

Thankfully, there is a way the issue can be mitigated: just
configure git with

  # ~/.config/git/attributes
  buildenv-*.zip diff=dockerfilezip

  # ~/.config/git/config
  [diff "dockerfilezip"]
  binary = true
  textconv = unzip -q -c -a

after which 'git diff' and friends will automatically show the
contents of the archive.

Note that the configuration above only works correctly if there
is a single file in the archive, but for us that's the case by
definition so it's not really a problem.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 .gitignore |  1 +
 refresh    | 21 +++++++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9414382
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+Dockerfile
diff --git a/refresh b/refresh
index 6cefd79..73b4f9e 100755
--- a/refresh
+++ b/refresh
@@ -29,7 +29,7 @@ class Dockerfile:
 
     PREFIX = "buildenv-"
     CROSS = "-cross-"
-    SUFFIX = ".Dockerfile"
+    SUFFIX = ".zip"
 
     # PROJECTS is a dictionary of dictionaries.
     # The key is the project name, as present in the Dockerfile name and
@@ -106,6 +106,8 @@ class Dockerfile:
 
     def refresh(self, lcitool):
 
+        dockerfile = pathlib.Path("./Dockerfile")
+
         args = [
             lcitool,
             "dockerfile",
@@ -128,9 +130,24 @@ class Dockerfile:
         if rc.returncode != 0:
             raise Exception("lcitool failed: {}".format(rc.stderr.decode()))
 
-        with self.path.open('w') as f:
+        with dockerfile.open('w') as f:
             print(rc.stdout.decode().strip(), file=f)
 
+        self.path.unlink()
+
+        args = [
+            "zip",
+            self.path,
+            dockerfile,
+        ]
+
+        rc = subprocess.run(args, capture_output=True)
+
+        if rc.returncode != 0:
+            raise Exception("zip failed: {}".format(rc.stderr.decode()))
+
+        dockerfile.unlink()
+
 
 class Application:
 
-- 
2.21.0

--
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