From 5a889e7d8dc6847c2d9a8ae526df7c974688a947 Mon Sep 17 00:00:00 2001 From: Chris Marusich Date: Mon, 19 Feb 2018 05:53:16 +0100 Subject: [PATCH 5/8] docker: Allow the addition of extra files into the image. * guix/docker.scm (build-docker-image): Add #:extra-items-dir keyword argument. --- guix/docker.scm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/guix/docker.scm b/guix/docker.scm index 305e8273b..ef92714e0 100644 --- a/guix/docker.scm +++ b/guix/docker.scm @@ -107,7 +107,8 @@ return \"a\"." (symlinks '()) (system (utsname:machine (uname))) (creation-time (current-time time-utc)) - (tmpdir "/tmp/docker-image")) + (tmpdir "/tmp/docker-image") + extra-items-dir) "Write to IMAGE a Docker image archive from the given store PATH. The image contains the closure of PATH, as specified in CLOSURE (a file produced by #:references-graphs). SYMLINKS must be a list of (SOURCE -> TARGET) tuples @@ -121,7 +122,12 @@ CREATION-TIME, a SRFI-19 time-utc object, as the creation time in metadata. TMPDIR is the name of the temporary working directory to use. This can be useful if you need to use a specific temporary directory, for example because the default temporary directory lies on a file system with insufficient -space." +space. + +EXTRA-ITEMS-DIR is the name of a directory containing extra files to add to +the image; the entire directory tree rooted at EXTRA-ITEMS-DIR will be copied +into the root directory of the image, so a file EXTRA-ITEMS-DIR/foo will wind +up at /foo in the final Docker image." (let ((closure (canonicalize-path closure)) (id (docker-id path)) (time (date->string (time-utc->date creation-time) "~4")) @@ -166,7 +172,12 @@ space." (map symlink-source symlinks)))) (for-each delete-file-recursively (map (compose topmost-component symlink-source) - symlinks))))) + symlinks)) + extra-items-dir + (zero? (apply system* "tar" "-rf" "layer.tar" + "-C" extra-items-dir + (append %tar-determinism-options + '("."))))))) (with-output-to-file "config.json" (lambda () -- 2.15.1