aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-03-21 21:51:29 +0000
committerChristopher Baines <mail@cbaines.net>2020-03-21 21:51:29 +0000
commitf119fac3e4714d07604ee764186d195b20e9ce3b (patch)
treecf05657d2f86408cb40ed060cf62f72efb1a1dbe
parentab4b71e4e021171200e8b8c31a77e0a7b121937f (diff)
downloadguix-multi-layer-docker-images.tar
guix-multi-layer-docker-images.tar.gz
Generate two layers for docker images in guix packmulti-layer-docker-images
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.
-rw-r--r--guix/scripts/pack.scm38
1 files 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