guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Guix in Docker for automated CD/CI of complex software


From: Vicente Eduardo
Subject: Guix in Docker for automated CD/CI of complex software
Date: Thu, 21 Nov 2019 08:41:22 -0600

Hello Guix Developers.

I am developing a project called MetaCall
(https://github.com/metacall/core), which is a library that allows
calling functions between programming languages. In short, it is a
polyglot that allows importing code from other languages and using it
as normal code.

Since one year ago (or more), I have been trying to package it with no
success. With Docker it has been relatively easily to do, but Docker
is not a good way of distributing software like MetaCall. Because as
it is a C/C++ project (and library), it should be able to be
distributed for link against it as a shared or static library and not
as a Docker image.

One of the last attempts I have done is trying Guix, and it seems to
be the definitive package system. With it I have achieved to package
MetaCall with Python and generate a tarball with all dependencies self
contained. This is a perfect solution to me, because I can distribute
the complete polyglot with a single zip, allowing it to be installed
in any distribution or any other package manager (npm, pip, nuget or
gem).

In order to achieve this I have developed a Docker image of Guix
(https://github.com/metacall/guix) based on Alpine Linux. I work a lot
with Docker because I am using MetaCall to build a FaaS (Function as a
Service) (https://metacall.io), and Docker is a great tool nowadays in
Cloud. So I my idea was to provide a Docker image of Guix to allow
building MetaCall inside a CI/CD environment like Travis or any other
well know managed CD/CI platform with free-tier.

Current Guix Docker image is based on one of the latest version of
Docker and it uses buildx, an extension of Docker that implements
extra functionality by means of Buildkit. This is needed because this
image needs to spawn new processes meanwhile it is being built, as
Guix uses a daemon that does exactly this when running commands, so it
required to provide that privilege.

If you want to try the Docker image, just run:
docker pull metacall/guix
docker run -it metacall/guix /bin/sh

And then you can run any command, or you can execute commands directly
like this:
docker run -it metacall/guix guix graph coreutils

The store and profile folder can be shared too if you want to make it
persistent in your PC and install programs there:
docker run -v /gnu:/gnu -v $HOME/.guix-profile/:/root/.guix-profile/
-it metacall/guix guix package -i guile guile-cairo

I hope it is useful for someone. I using it to build the complete
polyglot with support for Python, Ruby, NodeJS, JavaScript (V8) and C#
NetCore, which are the main supported languages and/or run-times
(https://github.com/metacall/distributable/blob/53caad582cd097c5e92798bf0ec16660bfc4030c/source/metacall.scm).
Although it is being difficult because MetaCall's build system is a
bit complex and relies a lot in CMake features like ExternalProject
(not allowed in Guix as it downloads during build time), I already
achieved to build it with Python.

You can take metacall/distributable as an example of how to use
metacall/guix image. This will be eventually run in a CI/CD too. For
building you only have to do is to run make. After building everything
you will see a tarball-pack.tar.gz in the out directory outside of the
container. Here is the build script:
https://github.com/metacall/distributable/blob/53caad582cd097c5e92798bf0ec16660bfc4030c/scripts/build.sh
. I will merge feature/guix-build into the master soon.

Thanks for reading.
Vicente.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]