From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id 2L+xM7+gV2bunAAAqHPOHw:P1 (envelope-from ) for ; Wed, 29 May 2024 23:40:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 2L+xM7+gV2bunAAAqHPOHw (envelope-from ) for ; Wed, 29 May 2024 23:40:15 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=autistici.org header.s=stigmate header.b=MxFVcprj; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1717018815; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=DFvx5tQ9zKr7KFZIaKLobu/a8SOHHJF9h0gtSVbm4CU=; b=iKXAlPQlrPDUR6ERWE+xLe9WHaPGzIZ9TFZ6M83SEoIkRG+R3GBsTRAoOIV0OYq3T49RLQ osRnsbAG7OKnaAPIWZ0UmYjk5eHyMerbKcj/1jcAyeJtB1hzi6x8n+Jesl1JIa4ApVoDbO ByAjS3F0f5c9bPH5HA4Ay8RoG9r1GjFCXrXVYAZqPiDv6KIzX9dhmkmI3w72putCoyCG7T vzIlpd3773/gvxVJinjCeXfl881T0bSeH3R4dFjbXOBGCZHbwY7LvfKePf3V4WgiQKUggL CiGuQpDAQX4ddkWddDLsF0QrlbvclVu/FKmAumPeoSdOYvSyFsMlqT1zAQdgOw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1717018815; a=rsa-sha256; cv=none; b=CSi23e/5tf5//vmy00qeGBn0342tuuI1jmDnHiF6GnQMxgIVJSJJ8tg+WAyiSPqqnuoONa ICYQsx8SWxBntQWspWvZMayWVfpztI3pKyuLkxUQXmNy8oStuGHYuPnbdJkrKYR7hVF6XM G/0Wh8jiw0roza1ALk7UOixsNVvp4/2m18oK5ZoaGs5YEcygMqcRnbXH/JuJ69G5EsJnD3 ByjsV+/R7n9h9poBCfpXJns/hL75Qxknq1fIaW6LQxp6/7bZrf9cSUARIiuAadxtcTCIFs 9+gvXxu5Yp5ypVwNsBXLTapuSI1BFoQyPPWFwN63fbu+31ax6MOUmY9egesMEw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=autistici.org header.s=stigmate header.b=MxFVcprj; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 94E1B67EDA for ; Wed, 29 May 2024 23:40:15 +0200 (CEST) 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 From: Giacomo Leidi via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -2.45 X-Spam-Score: -2.45 X-Migadu-Queue-Id: 94E1B67EDA X-Migadu-Scanner: mx11.migadu.com X-TUID: EfnKtyp/SKdr * 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