Subject: [bug#62153] [PATCH 1/2] guix: docker: Build layered image.

From: Simon Tournier <[email-masked]>
Date: Tue, 14 Mar 2023 09:19:51 +0100

Hi Oleg,

CC: core teams

On Tue, 14 Mar 2023 at 00:10, Oleg Pykhalov <[email-masked]> wrote:

>>> diff --git a/gnu/packages/aux-files/python/stream-layered-image.py b/gnu/packages/aux-files/python/stream-layered-image.py
>>> new file mode 100644
>>> index 0000000000..9ad2168c2d
>>> --- /dev/null
>>> +++ b/gnu/packages/aux-files/python/stream-layered-image.py
>>> @@ -0,0 +1,391 @@
>>> +"""
>>> +This script generates a Docker image from a set of store paths. Uses
>>> +Docker Image Specification v1.2 as reference [1].
>>
>> Instead of Python, would it possible to implement in Guile?  I mean,
>> does Python have something that is missing in Guile?
>>
>> The facility for manipulating Tar?  Something else?
>
> I think nothing else.  As I understand Python implemented Tar inside the
> language itself in 2500 lines of code by manipulating binary data.
>
>     /gnu/store/...-python-3.9.9/lib/python3.9/tarfile.py
>
> Technically it's probably possible to use tar utility with --append flag
> instead of opening a new file and streaming to it as the Python script
> does.  To be honest I would like not to write it in this way if the
> Python script does not block current patch for merge.

Ok, thanks for explaining.

> Also I don't see myself writing Tar implementation in Guile, yet.  ;-)

Maybe not reimplementing Tar in Guile, maybe just enough for working.
Or maybe some Guile bindings.  Or maybe something is already around for
the bootstrap story.

The use of external tools as Python for producing built-in Guix feature
will be the first time, no?

For what it is worth, I would prefer to consider the options before
emitting an opinion about dragging Python building/packing layered
Docker. :-)

> The Nix project uses this script heavily to build layered images, so it
> should be robust in terms of up to date to current Tar and Python
> implementations.

Do you mean this script is coming from Nix.  Well, in all cases, this
script is not trivial and so it requires Copyright for authorship.

[...]

> The following example shows common layers between images, which will be
> not tranfered if you load image inside Docker as well as pull and push:

Thanks for explaining.

Cheers,
simon

PS: I will be off-line these 2-3 next weeks.  So a lack of an answer
from me will not be a lack of interest. ;-)