Skip to content
Snippets Groups Projects
Unverified Commit 84dda5a9 authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

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'.
parent b1edfbc3
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ (define-module (guix docker) ...@@ -24,6 +24,7 @@ (define-module (guix docker)
#:select (delete-file-recursively #:select (delete-file-recursively
with-directory-excursion)) with-directory-excursion))
#:use-module (guix build store-copy) #:use-module (guix build store-copy)
#:use-module (srfi srfi-19)
#:use-module (rnrs bytevectors) #:use-module (rnrs bytevectors)
#:use-module (ice-9 match) #:use-module (ice-9 match)
#:export (build-docker-image)) #:export (build-docker-image))
...@@ -83,15 +84,18 @@ (define (config layer time arch) ...@@ -83,15 +84,18 @@ (define (config layer time arch)
(rootfs . ((type . "layers") (rootfs . ((type . "layers")
(diff_ids . (,(layer-diff-id layer))))))) (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 "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 contains the closure of PATH, as specified in CLOSURE (a file produced by
#:references-graphs). Use COMPRESSOR, a command such as '(\"gzip\" \"-9n\"), #: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 (let ((directory "/tmp/docker-image") ;temporary working directory
(closure (canonicalize-path closure)) (closure (canonicalize-path closure))
(id (docker-id path)) (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)) (arch (match (utsname:machine (uname))
("x86_64" "amd64") ("x86_64" "amd64")
("i686" "386") ("i686" "386")
......
...@@ -219,7 +219,7 @@ (define build ...@@ -219,7 +219,7 @@ (define build
(string-append #$guile-json "/share/guile/site/" (string-append #$guile-json "/share/guile/site/"
(effective-version))) (effective-version)))
(use-modules (guix docker)) (use-modules (guix docker) (srfi srfi-19))
(setenv "PATH" (setenv "PATH"
(string-append #$tar "/bin:" (string-append #$tar "/bin:"
...@@ -227,7 +227,8 @@ (define build ...@@ -227,7 +227,8 @@ (define build
(build-docker-image #$output #$profile (build-docker-image #$output #$profile
#:closure "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." (gexp->derivation (string-append name ".tar."
(compressor-extension compressor)) (compressor-extension compressor))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment