threefoldtech / rfs

A fuse filesystem in rust
Apache License 2.0
1 stars 1 forks source link

docker2flist #56

Closed xmonader closed 1 month ago

xmonader commented 10 months ago

First i suggest that the name should be docker2fl or docker2fungi, to not be confused with the older flist format.

The tool goal is to make it easier to build fl files from any docker image. IMHO the tool can be written in rust, this way it can very easily import and use the rfs library directly to create the fl, otherwise you will have to relay and use an external rfs binary to do so.

In general the process of the conversion has to go like this

NOTE: docker save can also output the tar to stdout it means the tool can directly untar the tar stream directly to a dir without the need to save it to disk first.

That is "almost" it.

But, there is an undocumented feature that is done by the current hub docker2flist. Since docker image also has meta about, entrypoint and env. which is not natively supported by the fl format (since the fl/flist format are mainly implementing the filesystem layer). The hub on conversion creates an extra file at the root of the directory before packing called .startup.toml this file is only used by zos if you going to run a workload. This file defines the default entrypoint and default env. The entrypoint can then be overridden by the deployment entrypoint if needed. The 2 envs (from the flist, and from the deployment) are merged.

Sample content of the file

[startup]

[startup.entry]
name = "core.system"

[startup.entry.args]
dir = "/" # workind dir as defined by the image meta
args = ["init"] # all the following args to the entrypoint
name = "zinit" # only name of the entrypoint binary

[startup.entry.args.env]
# list all env vars
PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

All toml entry names must be preserved. All the values that u need to set are values under startup.entry.args and startup.entry.args.env.

xmonader commented 10 months ago

let's see if we can do a docker subcommand if possible to register it, but if not let's go with a separate tool

p.s: https://www.youtube.com/watch?v=78IMA8xEBHA i didn't watch that, but maybe it gives a better option for docker integration

rawdaGastan commented 9 months ago

The tool is created, and it generated flists successfully from docker images. I noticed it takes a long time to pack an flist.

rawdaGastan commented 8 months ago

The tool is ready to be reviewed

WIP: working on the HTTP server of flists conversion, list and get