Package: guix-patches;
Reported by: paul <goodoldpaul <at> autistici.org>
Date: Wed, 29 May 2024 21:38:02 UTC
Severity: normal
Done: Zheng Junjie <zhengjunjie <at> iscas.ac.cn>
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 71263 in the body.
You can then email your comments to 71263 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Wed, 29 May 2024 21:38:02 GMT) Full text and rfc822 format available.paul <goodoldpaul <at> autistici.org>
:guix-patches <at> gnu.org
.
(Wed, 29 May 2024 21:38:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: paul <goodoldpaul <at> autistici.org> To: guix-patches <at> gnu.org Subject: Add additional fields to oci-container-configuration Date: Wed, 29 May 2024 23:37:30 +0200
Hello Guixers, I'm sending a patch series to add some fields to the oci-container-configuration . Thank you for your work giacomo
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Wed, 29 May 2024 21:40:02 GMT) Full text and rfc822 format available.Message #8 received at 71263 <at> debbugs.gnu.org (full text, mbox):
From: Giacomo Leidi <goodoldpaul <at> autistici.org> To: 71263 <at> debbugs.gnu.org Cc: Giacomo Leidi <goodoldpaul <at> autistici.org> Subject: [PATCH 1/5] doc: Minor changes to the OCI-backed Services documentation. Date: Wed, 29 May 2024 23:38:52 +0200
* doc/guix.texi: Clarify the example and remove reduntant escapes. Change-Id: I38f5517ae46b391ba21ae5a94c6dcc272e245036 --- doc/guix.texi | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index c1ff049f03..8662586b46 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40547,6 +40547,7 @@ Miscellaneous Services (service oci-container-service-type (list (oci-container-configuration + (network "host") (image (oci-image (repository "guile") @@ -40559,20 +40560,17 @@ Miscellaneous Services '("-c" "(display \"hello!\n\")"))) (oci-container-configuration (image "prom/prometheus") - (network "host") (ports '(("9000" . "9000") ("9090" . "9090")))) (oci-container-configuration (image "grafana/grafana:10.0.1") (network "host") - (ports - '(("3000" . "3000"))) (volumes '("/var/lib/grafana:/var/lib/grafana"))))) @end lisp -In this example two different Shepherd services are going be added to the +In this example three different Shepherd services are going be added to the system. Each @code{oci-container-configuration} record translates to a @code{docker run} invocation and its fields directly map to options. You can refer to the @@ -40580,8 +40578,8 @@ Miscellaneous Services documentation for the semantics of each value. If the images are not found they will be @url{https://docs.docker.com/engine/reference/commandline/pull/,pulled}. The -spawned services are going to be attached to the host network and are supposed -to behave like other processes. +services with @code{(network "host")} are going to be attached to the host network +and are supposed to behave like native processes with regard to networking. @end defvar @@ -40613,8 +40611,8 @@ Miscellaneous Services value can be a list of pairs or strings, even mixed: @lisp -(list '(\"LANGUAGE\" . \"eo:ca:eu\") - \"JAVA_HOME=/opt/java\") +(list '("LANGUAGE\" . "eo:ca:eu") + "JAVA_HOME=/opt/java") @end lisp Pair members can be strings, gexps or file-like objects. Strings are passed base-commit: 6f72ad465c1e2df965e8d73b209497b4ef456527 -- 2.41.0
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Wed, 29 May 2024 21:40:03 GMT) Full text and rfc822 format available.Message #11 received at 71263 <at> debbugs.gnu.org (full text, mbox):
From: Giacomo Leidi <goodoldpaul <at> autistici.org> To: 71263 <at> debbugs.gnu.org Cc: Giacomo Leidi <goodoldpaul <at> autistici.org> Subject: [PATCH 2/5] gnu: docker: Allow setting Shepherd log-file in oci-container-configuration. Date: Wed, 29 May 2024 23:38:53 +0200
* gnu/services/docker.scm (oci-container-configuration) [log-file]: New field; (oci-container-shepherd-service): use it. Change-Id: Icad29ac6342b6f5bafc0d9be13a93cee99674185 --- doc/guix.texi | 5 +++++ gnu/services/docker.scm | 36 ++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 8662586b46..954196b14c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40644,6 +40644,11 @@ Miscellaneous Services Set additional Shepherd services dependencies to the provisioned Shepherd service. +@item @code{log-file} (default: @code{""}) (type: string) +When @code{log-file} is set, it names the file to which the service's +standard output and standard error are redirected. @code{log-file} is created +if it does not exist, otherwise it is appended to. + @item @code{network} (default: @code{""}) (type: string) Set a Docker network for the spawned container. diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm index 7aff8dcc5f..678e8b1139 100644 --- a/gnu/services/docker.scm +++ b/gnu/services/docker.scm @@ -74,6 +74,7 @@ (define-module (gnu services docker) oci-container-configuration-image oci-container-configuration-provision oci-container-configuration-requirement + oci-container-configuration-log-file oci-container-configuration-network oci-container-configuration-ports oci-container-configuration-volumes @@ -461,6 +462,11 @@ (define-configuration/no-serialization oci-container-configuration (list-of-symbols '()) "Set additional Shepherd services dependencies to the provisioned Shepherd service.") + (log-file + (maybe-string) + "When @code{log-file} is set, it names the file to which the service’s +standard output and standard error are redirected. @code{log-file} is created +if it does not exist, otherwise it is appended to.") (network (maybe-string) "Set a Docker network for the spawned container.") @@ -669,12 +675,16 @@ (define (oci-container-shepherd-service config) (host-environment (oci-container-configuration-host-environment config)) (command (oci-container-configuration-command config)) + (log-file (oci-container-configuration-log-file config)) (provision (oci-container-configuration-provision config)) (requirement (oci-container-configuration-requirement config)) (image (oci-container-configuration-image config)) (image-reference (oci-image-reference image)) (options (oci-container-configuration->options config)) (name (guess-name provision image)) + (loader (if (oci-image? image) + (%oci-image-loader name image image-reference) + #f)) (extra-arguments (oci-container-configuration-extra-arguments config))) @@ -687,18 +697,20 @@ (define (oci-container-shepherd-service config) (if (oci-image? image) name image) ".")) (start #~(lambda () - (when #$(oci-image? image) - (invoke #$(%oci-image-loader - name image image-reference))) - (fork+exec-command - ;; docker run [OPTIONS] IMAGE [COMMAND] [ARG...] - (list #$docker "run" "--rm" "--name" #$name - #$@options #$@extra-arguments - #$image-reference #$@command) - #:user #$user - #:group #$group - #:environment-variables - (list #$@host-environment)))) + (when #$(oci-image? image) + (invoke #$loader)) + (fork+exec-command + ;; docker run [OPTIONS] IMAGE [COMMAND] [ARG...] + (list #$docker "run" "--rm" "--name" #$name + #$@options #$@extra-arguments + #$image-reference #$@command) + #:user #$user + #:group #$group + #$@(if (maybe-value-set? log-file) + (list #:log-file log-file) + '()) + #:environment-variables + (list #$@host-environment)))) (stop #~(lambda _ (invoke #$docker "rm" "-f" #$name))) -- 2.41.0
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Wed, 29 May 2024 21:40:04 GMT) Full text and rfc822 format available.Message #14 received at 71263 <at> debbugs.gnu.org (full text, mbox):
From: Giacomo Leidi <goodoldpaul <at> autistici.org> To: 71263 <at> debbugs.gnu.org Cc: Giacomo Leidi <goodoldpaul <at> autistici.org> Subject: [PATCH 3/5] gnu: docker: Allow setting Shepherd auto-start? in oci-container-configuration. Date: Wed, 29 May 2024 23:38:54 +0200
* gnu/services/docker.scm (oci-container-configuration) [auto-start?]: New field; (oci-container-shepherd-service): use it. Change-Id: Id093d93effbbec3e1be757f8be83cf5f62eaeda7 --- doc/guix.texi | 4 ++++ gnu/services/docker.scm | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 954196b14c..dfc4d65349 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40649,6 +40649,10 @@ Miscellaneous Services standard output and standard error are redirected. @code{log-file} is created if it does not exist, otherwise it is appended to. +@item @code{auto-start?} (default: @code{#t}) (type: boolean) +Whether this service should be started automatically by the Shepherd. If it +is @code{#f} the service has to be started manually with @command{herd start}. + @item @code{network} (default: @code{""}) (type: string) Set a Docker network for the spawned container. diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm index 678e8b1139..712ca14cba 100644 --- a/gnu/services/docker.scm +++ b/gnu/services/docker.scm @@ -75,6 +75,7 @@ (define-module (gnu services docker) oci-container-configuration-provision oci-container-configuration-requirement oci-container-configuration-log-file + oci-container-configuration-auto-start? oci-container-configuration-network oci-container-configuration-ports oci-container-configuration-volumes @@ -467,6 +468,10 @@ (define-configuration/no-serialization oci-container-configuration "When @code{log-file} is set, it names the file to which the service’s standard output and standard error are redirected. @code{log-file} is created if it does not exist, otherwise it is appended to.") + (auto-start? + (boolean #t) + "Whether this service should be started automatically by the Shepherd. If it +is @code{#f} the service has to be started manually with @command{herd start}.") (network (maybe-string) "Set a Docker network for the spawned container.") @@ -670,6 +675,8 @@ (define (oci-container-shepherd-service config) (oci-image-repository image)))))) (let* ((docker (file-append docker-cli "/bin/docker")) + (auto-start? + (oci-container-configuration-auto-start? config)) (user (oci-container-configuration-user config)) (group (oci-container-configuration-group config)) (host-environment @@ -691,6 +698,7 @@ (define (oci-container-shepherd-service config) (shepherd-service (provision `(,(string->symbol name))) (requirement `(dockerd user-processes ,@requirement)) (respawn? #f) + (auto-start? auto-start?) (documentation (string-append "Docker backed Shepherd service for " -- 2.41.0
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Wed, 29 May 2024 21:40:05 GMT) Full text and rfc822 format available.Message #17 received at 71263 <at> debbugs.gnu.org (full text, mbox):
From: Giacomo Leidi <goodoldpaul <at> autistici.org> To: 71263 <at> debbugs.gnu.org Cc: Giacomo Leidi <goodoldpaul <at> autistici.org> Subject: [PATCH 4/5] gnu: docker: Allow setting Shepherd respawn? in oci-container-configuration. Date: Wed, 29 May 2024 23:38:55 +0200
* gnu/services/docker.scm (oci-container-configuration) [respawn?]: New field; (oci-container-shepherd-service): use it. Change-Id: I0d6367607fd0fd41f90a54b33d80bf4d4f43dd8b --- doc/guix.texi | 4 ++++ gnu/services/docker.scm | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index dfc4d65349..9abdc77869 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40653,6 +40653,10 @@ Miscellaneous Services Whether this service should be started automatically by the Shepherd. If it is @code{#f} the service has to be started manually with @command{herd start}. +@item @code{respawn?} (default: @code{#f}) (type: boolean) +Whether to have Shepherd restart the service when it stops, for instance when +the underlying process dies. + @item @code{network} (default: @code{""}) (type: string) Set a Docker network for the spawned container. diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm index 712ca14cba..bc566e6316 100644 --- a/gnu/services/docker.scm +++ b/gnu/services/docker.scm @@ -76,6 +76,7 @@ (define-module (gnu services docker) oci-container-configuration-requirement oci-container-configuration-log-file oci-container-configuration-auto-start? + oci-container-configuration-respawn? oci-container-configuration-network oci-container-configuration-ports oci-container-configuration-volumes @@ -472,6 +473,10 @@ (define-configuration/no-serialization oci-container-configuration (boolean #t) "Whether this service should be started automatically by the Shepherd. If it is @code{#f} the service has to be started manually with @command{herd start}.") + (respawn? + (boolean #f) + "Whether to restart the service when it stops, for instance when the +underlying process dies.") (network (maybe-string) "Set a Docker network for the spawned container.") @@ -685,6 +690,8 @@ (define (oci-container-shepherd-service config) (log-file (oci-container-configuration-log-file config)) (provision (oci-container-configuration-provision config)) (requirement (oci-container-configuration-requirement config)) + (respawn? + (oci-container-configuration-respawn? config)) (image (oci-container-configuration-image config)) (image-reference (oci-image-reference image)) (options (oci-container-configuration->options config)) @@ -697,7 +704,7 @@ (define (oci-container-shepherd-service config) (shepherd-service (provision `(,(string->symbol name))) (requirement `(dockerd user-processes ,@requirement)) - (respawn? #f) + (respawn? respawn?) (auto-start? auto-start?) (documentation (string-append -- 2.41.0
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Wed, 29 May 2024 21:40:06 GMT) Full text and rfc822 format available.Message #20 received at 71263 <at> debbugs.gnu.org (full text, mbox):
From: Giacomo Leidi <goodoldpaul <at> autistici.org> To: 71263 <at> debbugs.gnu.org Cc: Giacomo Leidi <goodoldpaul <at> autistici.org> Subject: [PATCH 5/5] gnu: docker: Allow setting Shepherd actions in oci-container-configuration. Date: Wed, 29 May 2024 23:38:56 +0200
* gnu/services/docker.scm (oci-container-configuration) [shepherd-actions]: New field; (sanitize-shepherd-actions): sanitize it; (oci-container-shepherd-service): use it. Change-Id: I0ca9826542be7cb8ca280a07a9bff1a262c2a8a7 --- doc/guix.texi | 4 ++++ gnu/services/docker.scm | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 9abdc77869..4c137ee31e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40657,6 +40657,10 @@ Miscellaneous Services Whether to have Shepherd restart the service when it stops, for instance when the underlying process dies. +@item @code{shepherd-actions} (default: @code{'()}) (type: list-of-symbols) +This is a list of @code{shepherd-action} records defining actions supported +by the service. + @item @code{network} (default: @code{""}) (type: string) Set a Docker network for the spawned container. diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm index bc566e6316..78d7e2f04e 100644 --- a/gnu/services/docker.scm +++ b/gnu/services/docker.scm @@ -77,6 +77,7 @@ (define-module (gnu services docker) oci-container-configuration-log-file oci-container-configuration-auto-start? oci-container-configuration-respawn? + oci-container-configuration-shepherd-actions oci-container-configuration-network oci-container-configuration-ports oci-container-configuration-volumes @@ -328,6 +329,17 @@ (define (oci-sanitize-volumes value) ;; '(("/mnt/dir" . "/dir") "/run/current-system/profile:/java") (oci-sanitize-mixed-list "volumes" value ":")) +(define (oci-sanitize-shepherd-actions value) + (map + (lambda (el) + (if (shepherd-action? el) + el + (raise + (formatted-message + (G_ "shepherd-actions may only be shepherd-action records +but ~a was found") el)))) + value)) + (define (oci-sanitize-extra-arguments value) (define (valid? member) (or (string? member) @@ -477,6 +489,11 @@ (define-configuration/no-serialization oci-container-configuration (boolean #f) "Whether to restart the service when it stops, for instance when the underlying process dies.") + (shepherd-actions + (list '()) + "This is a list of @code{shepherd-action} records defining actions supported +by the service." + (sanitizer oci-sanitize-shepherd-actions)) (network (maybe-string) "Set a Docker network for the spawned container.") @@ -680,6 +697,7 @@ (define (oci-container-shepherd-service config) (oci-image-repository image)))))) (let* ((docker (file-append docker-cli "/bin/docker")) + (actions (oci-container-configuration-shepherd-actions config)) (auto-start? (oci-container-configuration-auto-start? config)) (user (oci-container-configuration-user config)) @@ -732,15 +750,17 @@ (define (oci-container-shepherd-service config) (actions (if (oci-image? image) '() - (list - (shepherd-action - (name 'pull) - (documentation - (format #f "Pull ~a's image (~a)." - name image)) - (procedure - #~(lambda _ - (invoke #$docker "pull" #$image)))))))))) + (append + (list + (shepherd-action + (name 'pull) + (documentation + (format #f "Pull ~a's image (~a)." + name image)) + (procedure + #~(lambda _ + (invoke #$docker "pull" #$image))))) + actions)))))) (define %oci-container-accounts (list (user-account -- 2.41.0
guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Tue, 11 Jun 2024 20:03:01 GMT) Full text and rfc822 format available.Message #23 received at 71263 <at> debbugs.gnu.org (full text, mbox):
From: paul <goodoldpaul <at> autistici.org> To: 71263 <at> debbugs.gnu.org Cc: Ludovic Courtès <ludo <at> gnu.org>, maxim.cournoyer <at> gmail.com, pelzflorian <at> pelzflorian.de, matt <at> excalamus.com Subject: [PATCH v2] Add additional fields to oci-container-configuration - Rebase on current master Date: Tue, 11 Jun 2024 22:01:57 +0200
Hello Guixers, I'm sending an updated patchset, rebased on current master. Thank you for your work, giacomo
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Tue, 11 Jun 2024 20:06:02 GMT) Full text and rfc822 format available.Message #26 received at 71263 <at> debbugs.gnu.org (full text, mbox):
From: Giacomo Leidi <goodoldpaul <at> autistici.org> To: 71263 <at> debbugs.gnu.org Cc: Giacomo Leidi <goodoldpaul <at> autistici.org> Subject: [PATCH v2 4/5] gnu: docker: Allow setting Shepherd respawn? in oci-container-configuration. Date: Tue, 11 Jun 2024 22:04:59 +0200
* gnu/services/docker.scm (oci-container-configuration) [respawn?]: New field; (oci-container-shepherd-service): use it. * doc/guix.texi: Document it. Change-Id: I0d6367607fd0fd41f90a54b33d80bf4d4f43dd8b --- doc/guix.texi | 4 ++++ gnu/services/docker.scm | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index cc3847eadb..6dae5939d5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40707,6 +40707,10 @@ Miscellaneous Services Whether this service should be started automatically by the Shepherd. If it is @code{#f} the service has to be started manually with @command{herd start}. +@item @code{respawn?} (default: @code{#f}) (type: boolean) +Whether to have Shepherd restart the service when it stops, for instance when +the underlying process dies. + @item @code{network} (default: @code{""}) (type: string) Set a Docker network for the spawned container. diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm index 712ca14cba..bc566e6316 100644 --- a/gnu/services/docker.scm +++ b/gnu/services/docker.scm @@ -76,6 +76,7 @@ (define-module (gnu services docker) oci-container-configuration-requirement oci-container-configuration-log-file oci-container-configuration-auto-start? + oci-container-configuration-respawn? oci-container-configuration-network oci-container-configuration-ports oci-container-configuration-volumes @@ -472,6 +473,10 @@ (define-configuration/no-serialization oci-container-configuration (boolean #t) "Whether this service should be started automatically by the Shepherd. If it is @code{#f} the service has to be started manually with @command{herd start}.") + (respawn? + (boolean #f) + "Whether to restart the service when it stops, for instance when the +underlying process dies.") (network (maybe-string) "Set a Docker network for the spawned container.") @@ -685,6 +690,8 @@ (define (oci-container-shepherd-service config) (log-file (oci-container-configuration-log-file config)) (provision (oci-container-configuration-provision config)) (requirement (oci-container-configuration-requirement config)) + (respawn? + (oci-container-configuration-respawn? config)) (image (oci-container-configuration-image config)) (image-reference (oci-image-reference image)) (options (oci-container-configuration->options config)) @@ -697,7 +704,7 @@ (define (oci-container-shepherd-service config) (shepherd-service (provision `(,(string->symbol name))) (requirement `(dockerd user-processes ,@requirement)) - (respawn? #f) + (respawn? respawn?) (auto-start? auto-start?) (documentation (string-append -- 2.45.1
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Tue, 11 Jun 2024 20:06:02 GMT) Full text and rfc822 format available.Message #29 received at 71263 <at> debbugs.gnu.org (full text, mbox):
From: Giacomo Leidi <goodoldpaul <at> autistici.org> To: 71263 <at> debbugs.gnu.org Cc: Giacomo Leidi <goodoldpaul <at> autistici.org> Subject: [PATCH v2 5/5] gnu: docker: Allow setting Shepherd actions in oci-container-configuration. Date: Tue, 11 Jun 2024 22:05:00 +0200
* gnu/services/docker.scm (oci-container-configuration) [shepherd-actions]: New field; (sanitize-shepherd-actions): sanitize it; (oci-container-shepherd-service): use it. * doc/guix.texi: Document it. Change-Id: I0ca9826542be7cb8ca280a07a9bff1a262c2a8a7 --- doc/guix.texi | 4 ++++ gnu/services/docker.scm | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 6dae5939d5..fd49ab860e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40711,6 +40711,10 @@ Miscellaneous Services Whether to have Shepherd restart the service when it stops, for instance when the underlying process dies. +@item @code{shepherd-actions} (default: @code{'()}) (type: list-of-symbols) +This is a list of @code{shepherd-action} records defining actions supported +by the service. + @item @code{network} (default: @code{""}) (type: string) Set a Docker network for the spawned container. diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm index bc566e6316..78d7e2f04e 100644 --- a/gnu/services/docker.scm +++ b/gnu/services/docker.scm @@ -77,6 +77,7 @@ (define-module (gnu services docker) oci-container-configuration-log-file oci-container-configuration-auto-start? oci-container-configuration-respawn? + oci-container-configuration-shepherd-actions oci-container-configuration-network oci-container-configuration-ports oci-container-configuration-volumes @@ -328,6 +329,17 @@ (define (oci-sanitize-volumes value) ;; '(("/mnt/dir" . "/dir") "/run/current-system/profile:/java") (oci-sanitize-mixed-list "volumes" value ":")) +(define (oci-sanitize-shepherd-actions value) + (map + (lambda (el) + (if (shepherd-action? el) + el + (raise + (formatted-message + (G_ "shepherd-actions may only be shepherd-action records +but ~a was found") el)))) + value)) + (define (oci-sanitize-extra-arguments value) (define (valid? member) (or (string? member) @@ -477,6 +489,11 @@ (define-configuration/no-serialization oci-container-configuration (boolean #f) "Whether to restart the service when it stops, for instance when the underlying process dies.") + (shepherd-actions + (list '()) + "This is a list of @code{shepherd-action} records defining actions supported +by the service." + (sanitizer oci-sanitize-shepherd-actions)) (network (maybe-string) "Set a Docker network for the spawned container.") @@ -680,6 +697,7 @@ (define (oci-container-shepherd-service config) (oci-image-repository image)))))) (let* ((docker (file-append docker-cli "/bin/docker")) + (actions (oci-container-configuration-shepherd-actions config)) (auto-start? (oci-container-configuration-auto-start? config)) (user (oci-container-configuration-user config)) @@ -732,15 +750,17 @@ (define (oci-container-shepherd-service config) (actions (if (oci-image? image) '() - (list - (shepherd-action - (name 'pull) - (documentation - (format #f "Pull ~a's image (~a)." - name image)) - (procedure - #~(lambda _ - (invoke #$docker "pull" #$image)))))))))) + (append + (list + (shepherd-action + (name 'pull) + (documentation + (format #f "Pull ~a's image (~a)." + name image)) + (procedure + #~(lambda _ + (invoke #$docker "pull" #$image))))) + actions)))))) (define %oci-container-accounts (list (user-account -- 2.45.1
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Tue, 11 Jun 2024 20:06:03 GMT) Full text and rfc822 format available.Message #32 received at 71263 <at> debbugs.gnu.org (full text, mbox):
From: Giacomo Leidi <goodoldpaul <at> autistici.org> To: 71263 <at> debbugs.gnu.org Cc: Giacomo Leidi <goodoldpaul <at> autistici.org> Subject: [PATCH v2 1/5] doc: Minor changes to the OCI-backed Services documentation. Date: Tue, 11 Jun 2024 22:04:56 +0200
* doc/guix.texi: Clarify the example and remove reduntant escapes. Change-Id: I38f5517ae46b391ba21ae5a94c6dcc272e245036 --- doc/guix.texi | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 769ca1399f..5a06d7cdc5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40601,6 +40601,7 @@ Miscellaneous Services (service oci-container-service-type (list (oci-container-configuration + (network "host") (image (oci-image (repository "guile") @@ -40613,20 +40614,17 @@ Miscellaneous Services '("-c" "(display \"hello!\n\")"))) (oci-container-configuration (image "prom/prometheus") - (network "host") (ports '(("9000" . "9000") ("9090" . "9090")))) (oci-container-configuration (image "grafana/grafana:10.0.1") (network "host") - (ports - '(("3000" . "3000"))) (volumes '("/var/lib/grafana:/var/lib/grafana"))))) @end lisp -In this example two different Shepherd services are going be added to the +In this example three different Shepherd services are going be added to the system. Each @code{oci-container-configuration} record translates to a @code{docker run} invocation and its fields directly map to options. You can refer to the @@ -40634,8 +40632,8 @@ Miscellaneous Services documentation for the semantics of each value. If the images are not found they will be @url{https://docs.docker.com/engine/reference/commandline/pull/,pulled}. The -spawned services are going to be attached to the host network and are supposed -to behave like other processes. +services with @code{(network "host")} are going to be attached to the host network +and are supposed to behave like native processes with regard to networking. @end defvar @@ -40667,8 +40665,8 @@ Miscellaneous Services value can be a list of pairs or strings, even mixed: @lisp -(list '(\"LANGUAGE\" . \"eo:ca:eu\") - \"JAVA_HOME=/opt/java\") +(list '("LANGUAGE\" . "eo:ca:eu") + "JAVA_HOME=/opt/java") @end lisp Pair members can be strings, gexps or file-like objects. Strings are passed base-commit: df5648daa1a5d097a430131bbff353b865b476b6 -- 2.45.1
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Tue, 11 Jun 2024 20:06:03 GMT) Full text and rfc822 format available.Message #35 received at 71263 <at> debbugs.gnu.org (full text, mbox):
From: Giacomo Leidi <goodoldpaul <at> autistici.org> To: 71263 <at> debbugs.gnu.org Cc: Giacomo Leidi <goodoldpaul <at> autistici.org> Subject: [PATCH v2 2/5] gnu: docker: Allow setting Shepherd log-file in oci-container-configuration. Date: Tue, 11 Jun 2024 22:04:57 +0200
* gnu/services/docker.scm (oci-container-configuration) [log-file]: New field; (oci-container-shepherd-service): use it. * doc/guix.texi: Document it. Change-Id: Icad29ac6342b6f5bafc0d9be13a93cee99674185 --- doc/guix.texi | 5 +++++ gnu/services/docker.scm | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5a06d7cdc5..40296fcd5f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40698,6 +40698,11 @@ Miscellaneous Services Set additional Shepherd services dependencies to the provisioned Shepherd service. +@item @code{log-file} (default: @code{""}) (type: string) +When @code{log-file} is set, it names the file to which the service's +standard output and standard error are redirected. @code{log-file} is created +if it does not exist, otherwise it is appended to. + @item @code{network} (default: @code{""}) (type: string) Set a Docker network for the spawned container. diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm index cc1201508c..678e8b1139 100644 --- a/gnu/services/docker.scm +++ b/gnu/services/docker.scm @@ -74,6 +74,7 @@ (define-module (gnu services docker) oci-container-configuration-image oci-container-configuration-provision oci-container-configuration-requirement + oci-container-configuration-log-file oci-container-configuration-network oci-container-configuration-ports oci-container-configuration-volumes @@ -461,6 +462,11 @@ (define-configuration/no-serialization oci-container-configuration (list-of-symbols '()) "Set additional Shepherd services dependencies to the provisioned Shepherd service.") + (log-file + (maybe-string) + "When @code{log-file} is set, it names the file to which the service’s +standard output and standard error are redirected. @code{log-file} is created +if it does not exist, otherwise it is appended to.") (network (maybe-string) "Set a Docker network for the spawned container.") @@ -669,12 +675,16 @@ (define (oci-container-shepherd-service config) (host-environment (oci-container-configuration-host-environment config)) (command (oci-container-configuration-command config)) + (log-file (oci-container-configuration-log-file config)) (provision (oci-container-configuration-provision config)) (requirement (oci-container-configuration-requirement config)) (image (oci-container-configuration-image config)) (image-reference (oci-image-reference image)) (options (oci-container-configuration->options config)) (name (guess-name provision image)) + (loader (if (oci-image? image) + (%oci-image-loader name image image-reference) + #f)) (extra-arguments (oci-container-configuration-extra-arguments config))) @@ -687,10 +697,8 @@ (define (oci-container-shepherd-service config) (if (oci-image? image) name image) ".")) (start #~(lambda () - #$@(if (oci-image? image) - #~((invoke #$(%oci-image-loader - name image image-reference))) - #~()) + (when #$(oci-image? image) + (invoke #$loader)) (fork+exec-command ;; docker run [OPTIONS] IMAGE [COMMAND] [ARG...] (list #$docker "run" "--rm" "--name" #$name @@ -698,6 +706,9 @@ (define (oci-container-shepherd-service config) #$image-reference #$@command) #:user #$user #:group #$group + #$@(if (maybe-value-set? log-file) + (list #:log-file log-file) + '()) #:environment-variables (list #$@host-environment)))) (stop -- 2.45.1
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Tue, 11 Jun 2024 20:06:03 GMT) Full text and rfc822 format available.Message #38 received at 71263 <at> debbugs.gnu.org (full text, mbox):
From: Giacomo Leidi <goodoldpaul <at> autistici.org> To: 71263 <at> debbugs.gnu.org Cc: Giacomo Leidi <goodoldpaul <at> autistici.org> Subject: [PATCH v2 3/5] gnu: docker: Allow setting Shepherd auto-start? in oci-container-configuration. Date: Tue, 11 Jun 2024 22:04:58 +0200
* gnu/services/docker.scm (oci-container-configuration) [auto-start?]: New field; (oci-container-shepherd-service): use it. * doc/guix.texi: Document it. Change-Id: Id093d93effbbec3e1be757f8be83cf5f62eaeda7 --- doc/guix.texi | 4 ++++ gnu/services/docker.scm | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 40296fcd5f..cc3847eadb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40703,6 +40703,10 @@ Miscellaneous Services standard output and standard error are redirected. @code{log-file} is created if it does not exist, otherwise it is appended to. +@item @code{auto-start?} (default: @code{#t}) (type: boolean) +Whether this service should be started automatically by the Shepherd. If it +is @code{#f} the service has to be started manually with @command{herd start}. + @item @code{network} (default: @code{""}) (type: string) Set a Docker network for the spawned container. diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm index 678e8b1139..712ca14cba 100644 --- a/gnu/services/docker.scm +++ b/gnu/services/docker.scm @@ -75,6 +75,7 @@ (define-module (gnu services docker) oci-container-configuration-provision oci-container-configuration-requirement oci-container-configuration-log-file + oci-container-configuration-auto-start? oci-container-configuration-network oci-container-configuration-ports oci-container-configuration-volumes @@ -467,6 +468,10 @@ (define-configuration/no-serialization oci-container-configuration "When @code{log-file} is set, it names the file to which the service’s standard output and standard error are redirected. @code{log-file} is created if it does not exist, otherwise it is appended to.") + (auto-start? + (boolean #t) + "Whether this service should be started automatically by the Shepherd. If it +is @code{#f} the service has to be started manually with @command{herd start}.") (network (maybe-string) "Set a Docker network for the spawned container.") @@ -670,6 +675,8 @@ (define (oci-container-shepherd-service config) (oci-image-repository image)))))) (let* ((docker (file-append docker-cli "/bin/docker")) + (auto-start? + (oci-container-configuration-auto-start? config)) (user (oci-container-configuration-user config)) (group (oci-container-configuration-group config)) (host-environment @@ -691,6 +698,7 @@ (define (oci-container-shepherd-service config) (shepherd-service (provision `(,(string->symbol name))) (requirement `(dockerd user-processes ,@requirement)) (respawn? #f) + (auto-start? auto-start?) (documentation (string-append "Docker backed Shepherd service for " -- 2.45.1
guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Fri, 05 Jul 2024 07:37:01 GMT) Full text and rfc822 format available.Message #41 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Zheng Junjie <zhengjunjie <at> iscas.ac.cn> To: Giacomo Leidi via Guix-patches via <guix-patches <at> gnu.org> Cc: Giacomo Leidi <goodoldpaul <at> autistici.org>, Maxim Cournoyer <maxim.cournoyer <at> gmail.com>, 71263 <at> debbugs.gnu.org, Ludovic Courtès <ludo <at> gnu.org>, Florian Pelz <pelzflorian <at> pelzflorian.de>, Matthew Trzcinski <matt <at> excalamus.com> Subject: Re: [bug#71263] [PATCH v2 2/5] gnu: docker: Allow setting Shepherd log-file in oci-container-configuration. Date: Fri, 05 Jul 2024 15:35:49 +0800
[Message part 1 (text/plain, inline)]
Giacomo Leidi via Guix-patches via <guix-patches <at> gnu.org> writes: > * gnu/services/docker.scm (oci-container-configuration) > [log-file]: New field; > (oci-container-shepherd-service): use it. > > * doc/guix.texi: Document it. > > Change-Id: Icad29ac6342b6f5bafc0d9be13a93cee99674185 > --- > doc/guix.texi | 5 +++++ > gnu/services/docker.scm | 19 +++++++++++++++---- > 2 files changed, 20 insertions(+), 4 deletions(-) > > diff --git a/doc/guix.texi b/doc/guix.texi > index 5a06d7cdc5..40296fcd5f 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -40698,6 +40698,11 @@ Miscellaneous Services > Set additional Shepherd services dependencies to the provisioned > Shepherd service. > > +@item @code{log-file} (default: @code{""}) (type: string) ^^^^^^^^^^^^^^^^^^^^ i remove it, because it is not "". > +@item @code{log-file} (default: @code{""}) (type: string) ^^^^^^ maybe-string > +When @code{log-file} is set, it names the file to which the service's > +standard output and standard error are redirected. @code{log-file} is created > +if it does not exist, otherwise it is appended to. > + > @item @code{network} (default: @code{""}) (type: string) > Set a Docker network for the spawned container. > > diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm > index cc1201508c..678e8b1139 100644 > --- a/gnu/services/docker.scm > +++ b/gnu/services/docker.scm > @@ -74,6 +74,7 @@ (define-module (gnu services docker) > oci-container-configuration-image > oci-container-configuration-provision > oci-container-configuration-requirement > + oci-container-configuration-log-file > oci-container-configuration-network > oci-container-configuration-ports > oci-container-configuration-volumes > @@ -461,6 +462,11 @@ (define-configuration/no-serialization oci-container-configuration > (list-of-symbols '()) > "Set additional Shepherd services dependencies to the provisioned Shepherd > service.") > + (log-file > + (maybe-string) > + "When @code{log-file} is set, it names the file to which the service’s > +standard output and standard error are redirected. @code{log-file} is created > +if it does not exist, otherwise it is appended to.") > (network > (maybe-string) > "Set a Docker network for the spawned container.") > @@ -669,12 +675,16 @@ (define (oci-container-shepherd-service config) > (host-environment > (oci-container-configuration-host-environment config)) > (command (oci-container-configuration-command config)) > + (log-file (oci-container-configuration-log-file config)) > (provision (oci-container-configuration-provision config)) > (requirement (oci-container-configuration-requirement config)) > (image (oci-container-configuration-image config)) > (image-reference (oci-image-reference image)) > (options (oci-container-configuration->options config)) > (name (guess-name provision image)) > + (loader (if (oci-image? image) > + (%oci-image-loader name image image-reference) > + #f)) > (extra-arguments > (oci-container-configuration-extra-arguments config))) > > @@ -687,10 +697,8 @@ (define (oci-container-shepherd-service config) > (if (oci-image? image) name image) ".")) > (start > #~(lambda () > - #$@(if (oci-image? image) > - #~((invoke #$(%oci-image-loader > - name image image-reference))) > - #~()) > + (when #$(oci-image? image) > + (invoke #$loader)) if (oci-image? image) return #f ``` (when #f (invoke #f)) ``` This is noise in the file. > (fork+exec-command > ;; docker run [OPTIONS] IMAGE [COMMAND] [ARG...] > (list #$docker "run" "--rm" "--name" #$name > @@ -698,6 +706,9 @@ (define (oci-container-shepherd-service config) > #$image-reference #$@command) > #:user #$user > #:group #$group > + #$@(if (maybe-value-set? log-file) > + (list #:log-file log-file) > + '()) > #:environment-variables > (list #$@host-environment)))) > (stop
[signature.asc (application/pgp-signature, inline)]
guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Fri, 05 Jul 2024 07:37:02 GMT) Full text and rfc822 format available.guix-patches <at> gnu.org
:bug#71263
; Package guix-patches
.
(Fri, 05 Jul 2024 07:43:02 GMT) Full text and rfc822 format available.Message #47 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Zheng Junjie <zhengjunjie <at> iscas.ac.cn> To: Giacomo Leidi via Guix-patches via <guix-patches <at> gnu.org> Cc: Giacomo Leidi <goodoldpaul <at> autistici.org>, Maxim Cournoyer <maxim.cournoyer <at> gmail.com>, Ludovic Courtès <ludo <at> gnu.org>, Florian Pelz <pelzflorian <at> pelzflorian.de>, 71263-done <at> debbugs.gnu.org, Matthew Trzcinski <matt <at> excalamus.com> Subject: Re: [bug#71263] [PATCH v2 1/5] doc: Minor changes to the OCI-backed Services documentation. Date: Fri, 05 Jul 2024 15:41:44 +0800
[Message part 1 (text/plain, inline)]
hello, pushed with some change. from https://git.savannah.gnu.org/cgit/guix.git/commit/?id=f5d0c324b1eb1129a70c04487e5f112cb1838f63 to https://git.savannah.gnu.org/cgit/guix.git/commit/?id=5ee2799cabba4b2d462ac064a98789d7bca07923 And 2-5 patch should prefix with "services: oci-container:", because this patches is impove oci-container-shepherd-service, not docker package.
[signature.asc (application/pgp-signature, inline)]
Zheng Junjie <zhengjunjie <at> iscas.ac.cn>
:paul <goodoldpaul <at> autistici.org>
:Debbugs Internal Request <help-debbugs <at> gnu.org>
to internal_control <at> debbugs.gnu.org
.
(Fri, 02 Aug 2024 11:24:05 GMT) Full text and rfc822 format available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.