From patchwork Wed May 29 21:38:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: paul X-Patchwork-Id: 27984 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CE4BB27BBE2; Wed, 29 May 2024 22:40:18 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6961A27BBE9 for ; Wed, 29 May 2024 22:40:17 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCR1X-0000nO-QC; Wed, 29 May 2024 17:39:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCR1W-0000mt-Te for guix-patches@gnu.org; Wed, 29 May 2024 17:39:54 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sCR1V-0001oE-IK; Wed, 29 May 2024 17:39:53 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sCR1e-0008D1-8r; Wed, 29 May 2024 17:40:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71263] [PATCH 1/5] doc: Minor changes to the OCI-backed Services documentation. References: <39e6b8e8-c1df-f5fb-5e43-f238d0d4067f@autistici.org> In-Reply-To: <39e6b8e8-c1df-f5fb-5e43-f238d0d4067f@autistici.org> Resent-From: Giacomo Leidi Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Wed, 29 May 2024 21:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71263 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 71263@debbugs.gnu.org Cc: Giacomo Leidi , Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by 71263-submit@debbugs.gnu.org id=B71263.171701876631399 (code B ref 71263); Wed, 29 May 2024 21:40:02 +0000 Received: (at 71263) by debbugs.gnu.org; 29 May 2024 21:39:26 +0000 Received: from localhost ([127.0.0.1]:55961 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR13-0008AJ-Bd for submit@debbugs.gnu.org; Wed, 29 May 2024 17:39:26 -0400 Received: from confino.investici.org ([93.190.126.19]:48531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR11-0008AA-36 for 71263@debbugs.gnu.org; Wed, 29 May 2024 17:39:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1717018752; bh=wMZoJp5SG5VLI0v9TimsUOowPD1K1DKB8UesoC6q+fw=; h=From:To:Cc:Subject:Date:From; b=UhBsluvyevlm4biWkspy+ANL2Uj0/43v81d24ZdTf4zY0M3Asnjhv8iF2Jo9bxN1t 1U4gG4rQq4n2X7fWspGI4QTxtGbBBM5u4rkHdArRWEyzDaqIrz3TtYRgD5CRHYxWtw HF4QSTWfPpDzPshCt/GXtPTIi86aHT0WH9Yi7Lwo= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4VqN7N2Qxqz1111; Wed, 29 May 2024 21:39:12 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4VqN7N1ll8z110x; Wed, 29 May 2024 21:39:12 +0000 (UTC) Date: Wed, 29 May 2024 23:38:52 +0200 Message-ID: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Giacomo Leidi X-ACL-Warn: , Giacomo Leidi via Guix-patches X-Patchwork-Original-From: Giacomo Leidi via Guix-patches via From: paul Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * doc/guix.texi: Clarify the example and remove reduntant escapes. Change-Id: I38f5517ae46b391ba21ae5a94c6dcc272e245036 --- doc/guix.texi | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) base-commit: 6f72ad465c1e2df965e8d73b209497b4ef456527 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 From patchwork Wed May 29 21:38:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: paul X-Patchwork-Id: 27983 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E57F227BBEC; Wed, 29 May 2024 22:40:17 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8425027BBE2 for ; Wed, 29 May 2024 22:40:15 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCR1Y-0000ne-Ag; Wed, 29 May 2024 17:39:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCR1W-0000mu-Uc for guix-patches@gnu.org; Wed, 29 May 2024 17:39:54 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sCR1W-0001oM-M0; Wed, 29 May 2024 17:39:54 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sCR1f-0008DE-BT; Wed, 29 May 2024 17:40:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71263] [PATCH 2/5] gnu: docker: Allow setting Shepherd log-file in oci-container-configuration. Resent-From: Giacomo Leidi Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Wed, 29 May 2024 21:40:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71263 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 71263@debbugs.gnu.org Cc: Giacomo Leidi , Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by 71263-submit@debbugs.gnu.org id=B71263.171701877231441 (code B ref 71263); Wed, 29 May 2024 21:40:03 +0000 Received: (at 71263) by debbugs.gnu.org; 29 May 2024 21:39:32 +0000 Received: from localhost ([127.0.0.1]:55971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR19-0008Ar-Fq for submit@debbugs.gnu.org; Wed, 29 May 2024 17:39:32 -0400 Received: from confino.investici.org ([93.190.126.19]:50981) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR18-0008Ab-Ex for 71263@debbugs.gnu.org; Wed, 29 May 2024 17:39:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1717018752; bh=DFvx5tQ9zKr7KFZIaKLobu/a8SOHHJF9h0gtSVbm4CU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MxFVcprjEZctnbxTK/kXoJZELQSRYbiYDN8WDOxliOekevAykTz2rAB59AgdzWNpE wZ6Aqm5nmmMHSMyGUarOIzXn7XvSPFm1oPgQwUBrUxbf/zl8vQ5/Z9QrqYuSMhbRkk tC3tbd/0uvZaaEENLnaClRjlHpsfnWBt05RDQvYo= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4VqN7N4HN1z1112; Wed, 29 May 2024 21:39:12 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4VqN7N3mKtz110x; Wed, 29 May 2024 21:39:12 +0000 (UTC) Date: Wed, 29 May 2024 23:38:53 +0200 Message-ID: <9377ac0cd61279e36e99ac54a14ca8d714c593f1.1717018735.git.goodoldpaul@autistici.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> References: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Giacomo Leidi X-ACL-Warn: , Giacomo Leidi via Guix-patches X-Patchwork-Original-From: Giacomo Leidi via Guix-patches via From: paul Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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))) From patchwork Wed May 29 21:38:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: paul X-Patchwork-Id: 27985 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 0B74627BBEA; Wed, 29 May 2024 22:40:25 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 78D7127BBE2 for ; Wed, 29 May 2024 22:40:24 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCR1Z-0000o4-14; Wed, 29 May 2024 17:39:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCR1X-0000n1-3c for guix-patches@gnu.org; Wed, 29 May 2024 17:39:55 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sCR1W-0001oV-R6; Wed, 29 May 2024 17:39:54 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sCR1g-0008DX-Hv; Wed, 29 May 2024 17:40:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71263] [PATCH 3/5] gnu: docker: Allow setting Shepherd auto-start? in oci-container-configuration. Resent-From: Giacomo Leidi Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Wed, 29 May 2024 21:40:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71263 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 71263@debbugs.gnu.org Cc: Giacomo Leidi , Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by 71263-submit@debbugs.gnu.org id=B71263.171701877731462 (code B ref 71263); Wed, 29 May 2024 21:40:04 +0000 Received: (at 71263) by debbugs.gnu.org; 29 May 2024 21:39:37 +0000 Received: from localhost ([127.0.0.1]:55973 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR1E-0008BN-E0 for submit@debbugs.gnu.org; Wed, 29 May 2024 17:39:36 -0400 Received: from confino.investici.org ([93.190.126.19]:55747) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR18-0008Ad-NQ for 71263@debbugs.gnu.org; Wed, 29 May 2024 17:39:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1717018752; bh=KPj89O7qluay/kshsG9dzmlaK4UL0JIfkYp9fhs98C4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TD1QzZ4QPHDklMJQYb/qufPJ0lttV55yAV0kMyLFf1wb0Rb5/rgg8uP1Y7Cq7yDPP 3S2R5WVqOqM2jxa5SRuJd5mnJSUMWkPQa+4aMNEPQPLRYWXGsIaNpcIQU4m9eyBOsz azuaotXfjgWKjDQG+nBo/33g0oX1z7z4QKvmPUl8= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4VqN7N65fPz1113; Wed, 29 May 2024 21:39:12 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4VqN7N5c2qz110x; Wed, 29 May 2024 21:39:12 +0000 (UTC) Date: Wed, 29 May 2024 23:38:54 +0200 Message-ID: <599079e06b2d086978ec21a1179f477c5497fc78.1717018736.git.goodoldpaul@autistici.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> References: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Giacomo Leidi X-ACL-Warn: , Giacomo Leidi via Guix-patches X-Patchwork-Original-From: Giacomo Leidi via Guix-patches via From: paul Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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 " From patchwork Wed May 29 21:38:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: paul X-Patchwork-Id: 27986 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 4223027BBE9; Wed, 29 May 2024 22:40:39 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 5FF3C27BBE2 for ; Wed, 29 May 2024 22:40:37 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCR1b-0000p6-8t; Wed, 29 May 2024 17:39:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCR1Y-0000ng-CD for guix-patches@gnu.org; Wed, 29 May 2024 17:39:56 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sCR1Y-0001oh-3E; Wed, 29 May 2024 17:39:56 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sCR1h-0008Do-Ja; Wed, 29 May 2024 17:40:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71263] [PATCH 4/5] gnu: docker: Allow setting Shepherd respawn? in oci-container-configuration. Resent-From: Giacomo Leidi Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Wed, 29 May 2024 21:40:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71263 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 71263@debbugs.gnu.org Cc: Giacomo Leidi , Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by 71263-submit@debbugs.gnu.org id=B71263.171701877731471 (code B ref 71263); Wed, 29 May 2024 21:40:05 +0000 Received: (at 71263) by debbugs.gnu.org; 29 May 2024 21:39:37 +0000 Received: from localhost ([127.0.0.1]:55975 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR1E-0008BP-W6 for submit@debbugs.gnu.org; Wed, 29 May 2024 17:39:37 -0400 Received: from confino.investici.org ([93.190.126.19]:65325) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR18-0008Ae-VX for 71263@debbugs.gnu.org; Wed, 29 May 2024 17:39:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1717018753; bh=eZhzPJEy3x83M2TJUQ+npHboyeD6jAJdPdkmO9YBH80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=usFSn410w/S3gKZCVbR6q6VLSUEE5r/t5dnZd88IEdcPjC35UoWMUsK9lTzdO0rsK gsmzTukVNC466z+BLfbxDzWfa1QU54KufCC0aS6o2pG+2+V/ZoYxge34I2nrYEFdef F9tYUfSmZWv72W2TZRtffcwHTAWC9HQ+qDEKmJi0= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4VqN7P0vTLz1116; Wed, 29 May 2024 21:39:13 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4VqN7P0LFLz110x; Wed, 29 May 2024 21:39:13 +0000 (UTC) Date: Wed, 29 May 2024 23:38:55 +0200 Message-ID: <4e9095471f8157305cb7b0e26cacd6580de344c2.1717018736.git.goodoldpaul@autistici.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> References: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Giacomo Leidi X-ACL-Warn: , Giacomo Leidi via Guix-patches X-Patchwork-Original-From: Giacomo Leidi via Guix-patches via From: paul Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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 From patchwork Wed May 29 21:38:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: paul X-Patchwork-Id: 27982 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 3AA9827BBEA; Wed, 29 May 2024 22:40:17 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A3BEA27BBE9 for ; Wed, 29 May 2024 22:40:16 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCR1a-0000p1-V5; Wed, 29 May 2024 17:39:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCR1Z-0000oQ-GI for guix-patches@gnu.org; Wed, 29 May 2024 17:39:57 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sCR1Z-0001os-7F; Wed, 29 May 2024 17:39:57 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sCR1i-0008E3-EZ; Wed, 29 May 2024 17:40:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71263] [PATCH 5/5] gnu: docker: Allow setting Shepherd actions in oci-container-configuration. Resent-From: Giacomo Leidi Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Wed, 29 May 2024 21:40:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71263 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 71263@debbugs.gnu.org Cc: Giacomo Leidi , Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by 71263-submit@debbugs.gnu.org id=B71263.171701877831477 (code B ref 71263); Wed, 29 May 2024 21:40:06 +0000 Received: (at 71263) by debbugs.gnu.org; 29 May 2024 21:39:38 +0000 Received: from localhost ([127.0.0.1]:55977 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR1F-0008BY-DC for submit@debbugs.gnu.org; Wed, 29 May 2024 17:39:37 -0400 Received: from confino.investici.org ([93.190.126.19]:27333) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR19-0008Af-7y for 71263@debbugs.gnu.org; Wed, 29 May 2024 17:39:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1717018753; bh=dYNFlJvCIPj1IpiBTm/0Bkd4FI18jAmcFmPwVBTWp30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rUshopFwlaSCxA9ajS0wwwnuzUPjeYzVq6EmoFc5CKeTS1Qu0eMZ1fLZaAb8op+W2 3o/haFBFeftmOFEj2Pg8dBc17NVOJl7cM85ZbVLKib2sT51co2SuA1EpqaHlD0B/a8 sgRYgW4mmRWVJNiOfz39r84xS4SKp3zBxVFDfiWs= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4VqN7P2lB1z1117; Wed, 29 May 2024 21:39:13 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4VqN7P2C32z110x; Wed, 29 May 2024 21:39:13 +0000 (UTC) Date: Wed, 29 May 2024 23:38:56 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> References: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Giacomo Leidi X-ACL-Warn: , Giacomo Leidi via Guix-patches X-Patchwork-Original-From: Giacomo Leidi via Guix-patches via From: paul Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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