MatrixAI / Emergence

Distributed Infrastructure Orchestration
Apache License 2.0
1 stars 0 forks source link

OCI image building #46

Closed nzhang-zh closed 5 years ago

nzhang-zh commented 5 years ago

Investigate methods to build OCI images and management via Nix. Start with building something similar to dockerTools in nixpkgs.


Tasks:

CMCDragonkai commented 5 years ago

@n-zhang-hp please check these related issues:

If they are related, please assign yourself there, or associate them into the relevant project board.

nzhang-zh commented 5 years ago

An initial ociTools attempt can be found here. 891b92bbe5561035e504891a7da99e47f9d39582 Closes #23

Completed:

  1. build single layer image
  2. combine multiple layers into a new image

Still need to squash multi layered image created in 2 down so it can be composed again. Also can not build layer with root permission currently.

nzhang-zh commented 5 years ago

Update: Dynamic linking issue can be resolved by creating a Nix store in the layer containing required dependencies. as seen in dockerTools.


The initial ociTools simply fetches packages from nixpkgs and dump them into oci image spec compatible images. This works for oci-image-tool and runc.

However, relevant paths for dynamic linking inside a container are different from nix environment or even unavailable.

We could either do static linking for packages with gcc .... -static (need to bring in glibc.static in this case) or use patchelf to modify paths for required dynamic libraries.

Or alternatively, this could be operator's responsibility to create properly linked/formed binary/library files.

nzhang-zh commented 5 years ago

Here is a summary of the discussion with @CMCDragonkai addressing how an Artefact should be built, stored and run.


Glossary

Storing Artefact

Image Archive is suitable for distribution of images therefore used by Docker. We should store Image Layouts instead to allow blobs sharing between different images. Overlays are also stored in the nix store.

Building Artefact

Blobs representing single layers should be linked in a composed Image Layout instead of copied.

Running Artefact

nzhang-zh commented 5 years ago

Since running OCI compatible image is more of a compatibility feature, apart from building oci images from scratch and combining them, we also need to fetch existing images from registries and build new images on top of them.

nzhang-zh commented 5 years ago

For nix based artefacts, instead of copying runtime dependencies into image layers, we can mount host nix store inside an automaton. Containers built this way will be really lightweight comparing to shipping all dependencies around.

This does require a host nix store to be present and has the outputs the automaton depends on.

Also, when an automaton is transferred between nodes, its closure must also be serialised and delivered.

nzhang-zh commented 5 years ago

Closing this in favour of #51 since our main objective for now is running OCI image based and Nix based artefacts rather than building OCI image with nix.