Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker2flist #56

Open
xmonader opened this issue Oct 31, 2023 · 3 comments
Open

docker2flist #56

xmonader opened this issue Oct 31, 2023 · 3 comments
Assignees
Milestone

Comments

@xmonader
Copy link
Contributor

xmonader commented Oct 31, 2023

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

  • Someone builds a docker image (using Dockerfile) or whatever
  • The docker2fungi tool will then save the image with docker save command this saves the image to a .tar file.
  • I have built a shell script that can extract this tar file to a directory that contains the extracted files here. Of course the tool can easily implement this itself, and not use the script 🤷🏼‍♂️
  • Once the dir is extracted, the rfs tool can be used to pack the directory creating the fl. Again i think it's really better to embed rfs library in the tool itself, (hence build the full thing in rust). Check first the rfs command line to see how to use @Omarabdul3ziz can help with that one. And I of course if u have questions

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
Copy link
Contributor Author

xmonader commented Oct 31, 2023

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
Copy link
Contributor

rawdaGastan commented Dec 17, 2023

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

@rawdaGastan
Copy link
Contributor

The tool is ready to be reviewed

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

@rawdaGastan rawdaGastan transferred this issue from threefoldtech/tfgrid-sdk-go May 22, 2024
@rawdaGastan rawdaGastan added this to the 2.1.X milestone May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Verification
Development

No branches or pull requests

4 participants