GNU bug report logs -
#66296
[PATCH] pack: Allow setting a custom image tag for Docker images
Previous Next
Reported by: soeren <at> soeren-tempel.net
Date: Sun, 1 Oct 2023 13:08:02 UTC
Severity: normal
Done: Mathieu Othacehe <mathieu <at> meije.mail-host-address-is-not-set>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 66296 in the body.
You can then email your comments to 66296 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#66296
; Package
guix-patches
.
(Sun, 01 Oct 2023 13:08:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
soeren <at> soeren-tempel.net
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Sun, 01 Oct 2023 13:08:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Sören Tempel <soeren <at> soeren-tempel.net>
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.
* guix/scripts/pack.scm (guix-pack): add --image-tag option
* guix/scripts/pack.scm (%docker-format-options): new constant
* guix/scripts/pack.scm (show-docker-format-options): new procedure
* guix/scripts/pack.scm (show-docker-format-options/detailed): new procedure
* guix/scripts/pack.scm (docker-image): allow setting a custom
repository name for the created docker image via extra-options.
Signed-off-by: Sören Tempel <soeren <at> soeren-tempel.net>
---
guix/scripts/pack.scm | 66 ++++++++++++++++++++++++++++++-------------
1 file changed, 46 insertions(+), 20 deletions(-)
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index 01995c48b7..e7005e7bc6 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -507,7 +507,7 @@ (define* (docker-image name profile
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
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
(and localstatedir?
(file-append (store-database (list profile))
@@ -531,7 +531,7 @@ (define build
(guix build utils)
(guix profiles) (guix search-paths)
(srfi srfi-1) (srfi srfi-19)
- (ice-9 match))
+ (ice-9 match) (ice-9 optargs))
#$(procedure-source manifest->friendly-name)
@@ -560,23 +560,26 @@ (define directives
(setenv "PATH" #+(file-append archiver "/bin"))
- (build-docker-image #$output
- (map store-info-item
- (call-with-input-file "profile"
- read-reference-graph))
- #$profile
- #:repository (manifest->friendly-name
- (profile-manifest #$profile))
- #:database #+database
- #:system (or #$target %host-type)
- #:environment environment
- #:entry-point
- #$(and entry-point
- #~(list (string-append #$profile "/"
- #$entry-point)))
- #:extra-files directives
- #:compressor #+(compressor-command compressor)
- #:creation-time (make-time time-utc 0 1))))))
+ (let-keywords '#$extra-options #f
+ ((image-tag #f))
+ (build-docker-image #$output
+ (map store-info-item
+ (call-with-input-file "profile"
+ read-reference-graph))
+ #$profile
+ #:repository (or image-tag
+ (manifest->friendly-name
+ (profile-manifest #$profile)))
+ #:database #+database
+ #:system (or #$target %host-type)
+ #:environment environment
+ #:entry-point
+ #$(and entry-point
+ #~(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"
(compressor-extension compressor))
@@ -1287,6 +1290,20 @@ (define (required-option symbol)
(alist-cons symbol arg result)
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
(list (required-option 'control-file)
(required-option 'postinst-file)
@@ -1407,6 +1424,10 @@ (define %options
(lambda (opt name arg 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
(lambda args
(show-deb-format-options/detailed)))
@@ -1415,7 +1436,8 @@ (define %options
(lambda args
(show-rpm-format-options/detailed)))
- (append %deb-format-options
+ (append %docker-format-options
+ %deb-format-options
%rpm-format-options
%transformation-options
%standard-build-options
@@ -1433,6 +1455,7 @@ (define (show-help)
(newline)
(show-transformation-options-help)
(newline)
+ (show-docker-format-options)
(show-deb-format-options)
(show-rpm-format-options)
(newline)
@@ -1586,6 +1609,9 @@ (define (process-file-arg opts name)
manifest)))
(pack-format (assoc-ref opts 'format))
(extra-options (match pack-format
+ ('docker
+ (list #:image-tag
+ (assoc-ref opts 'image-tag)))
('deb
(list #:control-file
(process-file-arg opts 'control-file)
Information forwarded
to
guix-patches <at> gnu.org
:
bug#66296
; Package
guix-patches
.
(Sat, 14 Oct 2023 08:24:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 66296 <at> debbugs.gnu.org (full text, mbox):
Hello,
> 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.
This seems to work fine, thanks. There is a line in the documentation
that states:
--8<---------------cut here---------------start------------->8---
The “repository name” as it appears in the output of the docker images
command is computed from package names passed on the command line or in
the manifest file.
--8<---------------cut here---------------end--------------->8---
Could you build upon that statement and introduce the new --image-tag
field there?
Thanks,
Mathieu
Information forwarded
to
guix-patches <at> gnu.org
:
bug#66296
; Package
guix-patches
.
(Sat, 14 Oct 2023 09:42:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 66296 <at> debbugs.gnu.org (full text, mbox):
From: Sören Tempel <soeren <at> soeren-tempel.net>
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.
* guix/scripts/pack.scm (guix-pack): add --image-tag option
* guix/scripts/pack.scm (%docker-format-options): new constant
* guix/scripts/pack.scm (show-docker-format-options): new procedure
* guix/scripts/pack.scm (show-docker-format-options/detailed): new procedure
* guix/scripts/pack.scm (docker-image): allow setting a custom
repository name for the created docker image via extra-options.
* doc/guix.texi (Invoking guix pack)[docker]: Document --image-tag option
Signed-off-by: Sören Tempel <soeren <at> soeren-tempel.net>
---
Changes since v1: Document the new --image-tag and --help-docker-format
options in the Guix manual (Invoking guix pack).
doc/guix.texi | 9 ++++--
guix/scripts/pack.scm | 66 ++++++++++++++++++++++++++++++-------------
2 files changed, 52 insertions(+), 23 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 8c5697589f..b9b45cfe9d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -7314,9 +7314,12 @@ specified binaries and symlinks.
@item docker
This produces a tarball that follows the
@uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
-Docker Image Specification}. The ``repository name'' as it appears in
-the output of the @command{docker images} command is computed from
-package names passed on the command line or in the manifest file.
+Docker Image Specification}. By default, the ``repository name'' as it
+appears in the output of the @command{docker images} command is computed
+from package names passed on the command line or in the manifest file.
+Alternatively, the ``repository name'' can also be configured via the
+@option{--image-tag} option. Refer to @option{--help-docker-format} for
+more information on such advanced options.
@item squashfs
This produces a SquashFS image containing all the specified binaries and
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index 01995c48b7..e7005e7bc6 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -507,7 +507,7 @@ (define* (docker-image name profile
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
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
(and localstatedir?
(file-append (store-database (list profile))
@@ -531,7 +531,7 @@ (define build
(guix build utils)
(guix profiles) (guix search-paths)
(srfi srfi-1) (srfi srfi-19)
- (ice-9 match))
+ (ice-9 match) (ice-9 optargs))
#$(procedure-source manifest->friendly-name)
@@ -560,23 +560,26 @@ (define directives
(setenv "PATH" #+(file-append archiver "/bin"))
- (build-docker-image #$output
- (map store-info-item
- (call-with-input-file "profile"
- read-reference-graph))
- #$profile
- #:repository (manifest->friendly-name
- (profile-manifest #$profile))
- #:database #+database
- #:system (or #$target %host-type)
- #:environment environment
- #:entry-point
- #$(and entry-point
- #~(list (string-append #$profile "/"
- #$entry-point)))
- #:extra-files directives
- #:compressor #+(compressor-command compressor)
- #:creation-time (make-time time-utc 0 1))))))
+ (let-keywords '#$extra-options #f
+ ((image-tag #f))
+ (build-docker-image #$output
+ (map store-info-item
+ (call-with-input-file "profile"
+ read-reference-graph))
+ #$profile
+ #:repository (or image-tag
+ (manifest->friendly-name
+ (profile-manifest #$profile)))
+ #:database #+database
+ #:system (or #$target %host-type)
+ #:environment environment
+ #:entry-point
+ #$(and entry-point
+ #~(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"
(compressor-extension compressor))
@@ -1287,6 +1290,20 @@ (define (required-option symbol)
(alist-cons symbol arg result)
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
(list (required-option 'control-file)
(required-option 'postinst-file)
@@ -1407,6 +1424,10 @@ (define %options
(lambda (opt name arg 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
(lambda args
(show-deb-format-options/detailed)))
@@ -1415,7 +1436,8 @@ (define %options
(lambda args
(show-rpm-format-options/detailed)))
- (append %deb-format-options
+ (append %docker-format-options
+ %deb-format-options
%rpm-format-options
%transformation-options
%standard-build-options
@@ -1433,6 +1455,7 @@ (define (show-help)
(newline)
(show-transformation-options-help)
(newline)
+ (show-docker-format-options)
(show-deb-format-options)
(show-rpm-format-options)
(newline)
@@ -1586,6 +1609,9 @@ (define (process-file-arg opts name)
manifest)))
(pack-format (assoc-ref opts 'format))
(extra-options (match pack-format
+ ('docker
+ (list #:image-tag
+ (assoc-ref opts 'image-tag)))
('deb
(list #:control-file
(process-file-arg opts 'control-file)
Reply sent
to
Mathieu Othacehe <othacehe <at> gnu.org>
:
You have taken responsibility.
(Sat, 14 Oct 2023 13:32:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
soeren <at> soeren-tempel.net
:
bug acknowledged by developer.
(Sat, 14 Oct 2023 13:32:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 66296-done <at> debbugs.gnu.org (full text, mbox):
Hello,
> * guix/scripts/pack.scm (guix-pack): add --image-tag option
> * guix/scripts/pack.scm (%docker-format-options): new constant
> * guix/scripts/pack.scm (show-docker-format-options): new procedure
> * guix/scripts/pack.scm (show-docker-format-options/detailed): new procedure
> * guix/scripts/pack.scm (docker-image): allow setting a custom
> repository name for the created docker image via extra-options.
> * doc/guix.texi (Invoking guix pack)[docker]: Document --image-tag option
Applied with an adapted commit message,
Thanks!
Mathieu
Did not alter fixed versions and reopened.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 15 Oct 2023 14:08:02 GMT)
Full text and
rfc822 format available.
Removed tag(s) patch.
Request was from
Ludovic Courtès <ludo <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Sun, 15 Oct 2023 14:08:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#66296
; Package
guix-patches
.
(Sun, 15 Oct 2023 14:13:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 66296 <at> debbugs.gnu.org (full text, mbox):
Hi,
soeren <at> soeren-tempel.net skribis:
> From: Sören Tempel <soeren <at> soeren-tempel.net>
>
> 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.
>
> * guix/scripts/pack.scm (guix-pack): add --image-tag option
> * guix/scripts/pack.scm (%docker-format-options): new constant
> * guix/scripts/pack.scm (show-docker-format-options): new procedure
> * guix/scripts/pack.scm (show-docker-format-options/detailed): new procedure
> * guix/scripts/pack.scm (docker-image): allow setting a custom
> repository name for the created docker image via extra-options.
> * doc/guix.texi (Invoking guix pack)[docker]: Document --image-tag option
>
> Signed-off-by: Sören Tempel <soeren <at> soeren-tempel.net>
It looks like commit 373ec2cf8ce97d5f89191c3d9211ee3a5c2067dc does not
include the pack.scm changes, only documentation.
Ludo’.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#66296
; Package
guix-patches
.
(Mon, 16 Oct 2023 07:30:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 66296 <at> debbugs.gnu.org (full text, mbox):
> It looks like commit 373ec2cf8ce97d5f89191c3d9211ee3a5c2067dc does not
> include the pack.scm changes, only documentation.
Fixed with 435090fa3f406a76c83e11de9cd01f61ef89dcca.
Thanks for the heads-up,
Mathieu
bug closed, send any further explanations to
66296 <at> debbugs.gnu.org and soeren <at> soeren-tempel.net
Request was from
Mathieu Othacehe <mathieu <at> meije.mail-host-address-is-not-set>
to
control <at> debbugs.gnu.org
.
(Wed, 25 Oct 2023 10:00:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 22 Nov 2023 12:24:18 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 212 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.