guix-devel
[Top][All Lists]
Advanced

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

[PATCH 3/3] Generate two layers for docker images in guix pack


From: Christopher Baines
Subject: [PATCH 3/3] Generate two layers for docker images in guix pack
Date: Sat, 21 Mar 2020 23:24:28 +0000

Split the store items in to two layers, the top layer with the profile and the
store items it directly references, and the bottom layer with the rest of the
store items.

This means that when you use pack and slightly vary the packages being packed,
for example by changing the versions or sources, the base layer will be
unchanged.
---
 guix/scripts/pack.scm | 38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index a9e9e7a415..698af73d28 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -560,19 +560,31 @@ the image."
    (docker-image
     (string-append name ".tar"
                    (compressor-extension compressor))
-    (list (docker-image-layer
-           "pack-docker-image-layer"
-           (with-store store
-             (let ((output
-                    (build-derivations store (list profile)))
-                   (path
-                    (derivation-output-path
-                     (match (derivation-outputs profile)
-                       (((name . derivation-output))
-                        derivation-output)))))
-               (requisites store (list path))))
-           ;;#:extra-files directives
-           ))
+    (with-store store
+      (let* ((output
+              (build-derivations store (list profile)))
+             (path
+              (derivation-output-path
+               (match (derivation-outputs profile)
+                 (((name . derivation-output))
+                  derivation-output))))
+             (refs
+              (references store path))
+             (reqs
+              (requisites store (list path))))
+
+        (list (docker-image-layer
+               "pack-docker-image-layer"
+               (sort (filter (lambda (path)
+                               (not (member path refs)))
+                             reqs)
+                     string<?))
+              (docker-image-layer
+               "pack-docker-image-layer"
+               (sort (filter (lambda (path)
+                               (member path refs))
+                             reqs)
+                     string<?)))))
     #:repository tag
     #:environment environment
     #:entry-point (and entry-point
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]