pack: Allow setting a custom image tag for Docker images
Previously, the image repository name was automatically computed from
the packages in the manifest without allowing the user to set a custom
one. As such, changing the packages in the manifest would result in a
new image name. Thereby requiring updating documentation et cetera when
using `docker load` directory on the resulting image.
Inspired by `docker build -t`, this commit adds a new Docker-specific
option to `guix pack` which allows setting a custom repository name for
the resulting image. If this option is not specified, pack falls back
to computing the name from the manifest. Therefore, this change is
entirely backwards compatible.
Documentation has been added with: 373ec2cf8c
.
* guix/scripts/pack.scm (guix-pack): Add --image-tag option.
(%docker-format-options): New constant.
(show-docker-format-options): New procedure.
(show-docker-format-options/detailed): New procedure.
(docker-image): Allow setting a custom
repository name for the created docker image via extra-options.
Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
This commit is contained in:
parent
a0d2ecde94
commit
435090fa3f
1 changed files with 50 additions and 20 deletions
|
@ -507,7 +507,7 @@ added to the pack."
|
||||||
image is a tarball conforming to the Docker Image Specification, compressed
|
image is a tarball conforming to the Docker Image Specification, compressed
|
||||||
with COMPRESSOR. It can be passed to 'docker load'. If TARGET is true, it
|
with COMPRESSOR. It can be passed to 'docker load'. If TARGET is true, it
|
||||||
must a be a GNU triplet and it is used to derive the architecture metadata in
|
must a be a GNU triplet and it is used to derive the architecture metadata in
|
||||||
the image."
|
the image. EXTRA-OPTIONS may contain the IMAGE-TAG keyword argument."
|
||||||
(define database
|
(define database
|
||||||
(and localstatedir?
|
(and localstatedir?
|
||||||
(file-append (store-database (list profile))
|
(file-append (store-database (list profile))
|
||||||
|
@ -531,7 +531,7 @@ the image."
|
||||||
(guix build utils)
|
(guix build utils)
|
||||||
(guix profiles) (guix search-paths)
|
(guix profiles) (guix search-paths)
|
||||||
(srfi srfi-1) (srfi srfi-19)
|
(srfi srfi-1) (srfi srfi-19)
|
||||||
(ice-9 match))
|
(ice-9 match) (ice-9 optargs))
|
||||||
|
|
||||||
#$(procedure-source manifest->friendly-name)
|
#$(procedure-source manifest->friendly-name)
|
||||||
|
|
||||||
|
@ -560,23 +560,30 @@ the image."
|
||||||
|
|
||||||
(setenv "PATH" #+(file-append archiver "/bin"))
|
(setenv "PATH" #+(file-append archiver "/bin"))
|
||||||
|
|
||||||
(build-docker-image #$output
|
(let-keywords '#$extra-options #f
|
||||||
(map store-info-item
|
((image-tag #f))
|
||||||
(call-with-input-file "profile"
|
(build-docker-image #$output
|
||||||
read-reference-graph))
|
(map store-info-item
|
||||||
#$profile
|
(call-with-input-file "profile"
|
||||||
#:repository (manifest->friendly-name
|
read-reference-graph))
|
||||||
(profile-manifest #$profile))
|
#$profile
|
||||||
#:database #+database
|
#:repository
|
||||||
#:system (or #$target %host-type)
|
(or image-tag
|
||||||
#:environment environment
|
(manifest->friendly-name
|
||||||
#:entry-point
|
(profile-manifest #$profile)))
|
||||||
#$(and entry-point
|
#:database #+database
|
||||||
#~(list (string-append #$profile "/"
|
#:system (or #$target %host-type)
|
||||||
#$entry-point)))
|
#:environment environment
|
||||||
#:extra-files directives
|
#:entry-point
|
||||||
#:compressor #+(compressor-command compressor)
|
#$(and entry-point
|
||||||
#:creation-time (make-time time-utc 0 1))))))
|
#~(list
|
||||||
|
(string-append #$profile "/"
|
||||||
|
#$entry-point)))
|
||||||
|
#:extra-files directives
|
||||||
|
#: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))
|
||||||
|
@ -1287,6 +1294,20 @@ last resort for relocation."
|
||||||
(alist-cons symbol arg result)
|
(alist-cons symbol arg result)
|
||||||
rest))))
|
rest))))
|
||||||
|
|
||||||
|
(define %docker-format-options
|
||||||
|
(list (required-option 'image-tag)))
|
||||||
|
|
||||||
|
(define (show-docker-format-options)
|
||||||
|
(display (G_ "
|
||||||
|
--help-docker-format list options specific to the docker format")))
|
||||||
|
|
||||||
|
(define (show-docker-format-options/detailed)
|
||||||
|
(display (G_ "
|
||||||
|
--image-tag=NAME
|
||||||
|
Use the given NAME for the Docker image repository"))
|
||||||
|
(newline)
|
||||||
|
(exit 0))
|
||||||
|
|
||||||
(define %deb-format-options
|
(define %deb-format-options
|
||||||
(list (required-option 'control-file)
|
(list (required-option 'control-file)
|
||||||
(required-option 'postinst-file)
|
(required-option 'postinst-file)
|
||||||
|
@ -1407,6 +1428,10 @@ last resort for relocation."
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(alist-cons 'bootstrap? #t result)))
|
(alist-cons 'bootstrap? #t result)))
|
||||||
|
|
||||||
|
(option '("help-docker-format") #f #f
|
||||||
|
(lambda args
|
||||||
|
(show-docker-format-options/detailed)))
|
||||||
|
|
||||||
(option '("help-deb-format") #f #f
|
(option '("help-deb-format") #f #f
|
||||||
(lambda args
|
(lambda args
|
||||||
(show-deb-format-options/detailed)))
|
(show-deb-format-options/detailed)))
|
||||||
|
@ -1415,7 +1440,8 @@ last resort for relocation."
|
||||||
(lambda args
|
(lambda args
|
||||||
(show-rpm-format-options/detailed)))
|
(show-rpm-format-options/detailed)))
|
||||||
|
|
||||||
(append %deb-format-options
|
(append %docker-format-options
|
||||||
|
%deb-format-options
|
||||||
%rpm-format-options
|
%rpm-format-options
|
||||||
%transformation-options
|
%transformation-options
|
||||||
%standard-build-options
|
%standard-build-options
|
||||||
|
@ -1433,6 +1459,7 @@ Create a bundle of PACKAGE.\n"))
|
||||||
(newline)
|
(newline)
|
||||||
(show-transformation-options-help)
|
(show-transformation-options-help)
|
||||||
(newline)
|
(newline)
|
||||||
|
(show-docker-format-options)
|
||||||
(show-deb-format-options)
|
(show-deb-format-options)
|
||||||
(show-rpm-format-options)
|
(show-rpm-format-options)
|
||||||
(newline)
|
(newline)
|
||||||
|
@ -1586,6 +1613,9 @@ Create a bundle of PACKAGE.\n"))
|
||||||
manifest)))
|
manifest)))
|
||||||
(pack-format (assoc-ref opts 'format))
|
(pack-format (assoc-ref opts 'format))
|
||||||
(extra-options (match pack-format
|
(extra-options (match pack-format
|
||||||
|
('docker
|
||||||
|
(list #:image-tag
|
||||||
|
(assoc-ref opts 'image-tag)))
|
||||||
('deb
|
('deb
|
||||||
(list #:control-file
|
(list #:control-file
|
||||||
(process-file-arg opts 'control-file)
|
(process-file-arg opts 'control-file)
|
||||||
|
|
Reference in a new issue