From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roel Janssen Subject: Re: Creating Docker containers in Scheme Date: Wed, 08 Nov 2017 10:38:17 +0100 Message-ID: <87h8u5yut2.fsf@gnu.org> References: <87lgjoiuf1.fsf@gnu.org> <87d14tw456.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCMob-0005sH-1f for guix-devel@gnu.org; Wed, 08 Nov 2017 04:38:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCMoa-0001Zt-4C for guix-devel@gnu.org; Wed, 08 Nov 2017 04:38:33 -0500 In-reply-to: <87d14tw456.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel Ludovic Courtès writes: > Hi, > > Roel Janssen skribis: > >> I'd like to create a Docker container from Scheme. Looking at >> guix/scripts/pack.scm, I believe something like this should be possible: >> >> (docker-image "my-container" >> (profile-derivation >> (packages->manifest (list hello coreutils)))) > > Move precisely: > > (mlet %store-monad ((profile (profile-derivation …))) > (docker-image "my-container" profile)) > Oh, of course! :) Unfortunately, I cannot seem to get it to work. Here's what I do (mind the GWL process- stuff): --8<---------------cut here---------------start------------->8--- (define* (process->docker-derivation proc #:key (guile (default-guile))) "Return a Docker container that can run the PROCEDURE described in PROC, with PROCEDURE's imported modules in its search path." (let ((name (process-full-name proc)) (exp (process-procedure proc)) (out (process-output-path proc)) (packages (process-package-inputs proc))) (let ((out-str (if out (format #f "(setenv \"out\" ~s)" out) ""))) (mlet %store-monad ((set-load-path (load-path-expression (gexp-modules exp))) (container (docker-image (string-append (process-full-name proc) "-docker") (profile-derivation (packages->manifest packages))))) (gexp->derivation name (gexp (call-with-output-file (ungexp output) (lambda (port) (format port "# Docker image: ~a~%" (ungexp container))))) #:graft? #f))))) --8<---------------cut here---------------end--------------->8--- And the error I get is: wrong-type-arg: string-prefix? Is there anything obviously wrong here? >> Is this something we could add to the the public interface of a module? > > Sure. For now the easiest solution would be to export ‘docker-image’ > from (guix scripts pack). > > Longer-term, we could rename (guix docker) to (guix build docker) and > move ‘docker-image’ to a new (guix docker) module, but perhaps we’d also > need a (guix pack) modules containing tools that are shared between the > docker and tarball backends of ‘guix pack’. > > WDYT? It'd be nice to keep the (guix scripts ...) small, and only do command-line handling. So I think a (guix build docker), and a (guix pack) module would be good. > > Ludo’. Thanks for your time! Kind regards, Roel Janssen