guix-commits
[Top][All Lists]
Advanced

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

07/12: pack: Use a fixed timestamp in Docker images.


From: Ludovic Courtès
Subject: 07/12: pack: Use a fixed timestamp in Docker images.
Date: Thu, 16 Mar 2017 18:04:24 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 84dda5a9c0772b2507fab3209938ead9da2a3442
Author: Ludovic Courtès <address@hidden>
Date:   Thu Mar 16 21:41:38 2017 +0100

    pack: Use a fixed timestamp in Docker images.
    
    * guix/docker.scm (build-docker-image): Add #:creation-time parameter.
    Use SRFI-19 'date->string' instead of 'strftime' et al.
    * guix/scripts/pack.scm (docker-image)[build]: Pass #:creation-time to
    'build-docker-image'.
---
 guix/docker.scm       | 10 +++++++---
 guix/scripts/pack.scm |  5 +++--
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/guix/docker.scm b/guix/docker.scm
index 56a0f7e..5614ab2 100644
--- a/guix/docker.scm
+++ b/guix/docker.scm
@@ -24,6 +24,7 @@
                 #:select (delete-file-recursively
                           with-directory-excursion))
   #:use-module (guix build store-copy)
+  #:use-module (srfi srfi-19)
   #:use-module (rnrs bytevectors)
   #:use-module (ice-9 match)
   #:export (build-docker-image))
@@ -83,15 +84,18 @@
     (rootfs . ((type . "layers")
                (diff_ids . (,(layer-diff-id layer)))))))
 
-(define* (build-docker-image image path #:key closure compressor)
+(define* (build-docker-image image path
+                             #:key closure compressor
+                             (creation-time (current-time time-utc)))
   "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).  Use COMPRESSOR, a command such as '(\"gzip\" \"-9n\"),
-to compress IMAGE."
+to compress IMAGE.  Use CREATION-TIME, a SRFI-19 time-utc object, as the
+creation time in metadata."
   (let ((directory "/tmp/docker-image")           ;temporary working directory
         (closure (canonicalize-path closure))
         (id (docker-id path))
-        (time (strftime "%FT%TZ" (localtime (current-time))))
+        (time (date->string (time-utc->date creation-time) "~4"))
         (arch (match (utsname:machine (uname))
                 ("x86_64" "amd64")
                 ("i686"   "386")
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index c6f2145..694b2f2 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -219,7 +219,7 @@ with COMPRESSOR.  It can be passed to 'docker load'."
            (string-append #$guile-json "/share/guile/site/"
                           (effective-version)))
 
-          (use-modules (guix docker))
+          (use-modules (guix docker) (srfi srfi-19))
 
           (setenv "PATH"
                   (string-append #$tar "/bin:"
@@ -227,7 +227,8 @@ with COMPRESSOR.  It can be passed to 'docker load'."
 
           (build-docker-image #$output #$profile
                               #:closure "profile"
-                              #:compressor '#$(compressor-command 
compressor)))))
+                              #:compressor '#$(compressor-command compressor)
+                              #:creation-time (make-time time-utc 0 1)))))
 
   (gexp->derivation (string-append name ".tar."
                                    (compressor-extension compressor))



reply via email to

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