From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eooFP-00039m-BH for guix-patches@gnu.org; Thu, 22 Feb 2018 05:37:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eooFM-0002wt-8P for guix-patches@gnu.org; Thu, 22 Feb 2018 05:37:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:47424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eooFM-0002wf-4P for guix-patches@gnu.org; Thu, 22 Feb 2018 05:37:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eooFL-0006se-UO for guix-patches@gnu.org; Thu, 22 Feb 2018 05:37:03 -0500 Subject: [bug#30572] [PATCH 5/7] docker: Allow the addition of extra files into the image. Resent-Message-ID: From: Chris Marusich Date: Thu, 22 Feb 2018 11:35:26 +0100 Message-Id: <20180222103528.5108-5-cmmarusich@gmail.com> In-Reply-To: <20180222103528.5108-1-cmmarusich@gmail.com> References: <20180222103528.5108-1-cmmarusich@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 30572@debbugs.gnu.org Cc: Chris Marusich * guix/docker.scm (build-docker-image): Add #:extra-items-dir keyword argument. --- guix/docker.scm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/guix/docker.scm b/guix/docker.scm index 693b4426f..1b9b36a3b 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")) + (tmpdir "/tmp") + 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 ((directory (string-append tmpdir "/docker-image")) ;temporary working directory (closure (canonicalize-path closure)) (id (docker-id path)) @@ -165,9 +171,14 @@ space." (append %tar-determinism-options items (map symlink-source symlinks)))) - (for-each delete-file-recursively - (map (compose topmost-component symlink-source) - symlinks))))) + (begin + (for-each delete-file-recursively + (map (compose topmost-component symlink-source) + symlinks)) + (zero? (apply system* "tar" "-C" extra-items-dir + "-rf" "layer.tar" + (append %tar-determinism-options + '(".")))))))) (with-output-to-file "config.json" (lambda () -- 2.15.1