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

Build a graph of file trees before generating the tar stream #55

Merged
merged 3 commits into from
Nov 11, 2022

Conversation

nlewo
Copy link
Owner

@nlewo nlewo commented Oct 27, 2022

Before this commit, nix2container read the file tree of store paths and write all file in the order they are walked by the os.Walk Go function.

In this commit, the build process contains now two steps:

  1. file trees are read and a graph representing these files is built
  2. this graph is walk to write files to the tar stream

This allows to easily transform the file tree (filename rewritting for instance) and also allow to easily detect duplicated files.

@nlewo nlewo changed the title Build a graph of file tree before generating the tar stream Build a graph of file trees before generating the tar stream Oct 27, 2022
This was referenced Oct 27, 2022
Before this commit, nix2container read the file tree of store paths
and write all file in the order they are walked by the os.Walk Go
function.

In this commit, the build process contains now two steps:
1. file trees are read and a graph representing these files is built
2. this graph is walk to write files to the tar stream

This allows to easily transform the file tree (filename rewritting for
instance) and also allow to easily detect duplicated files.
@nlewo nlewo marked this pull request as ready for review October 28, 2022 16:52
@nktpro
Copy link

nktpro commented Oct 29, 2022

I tested with some of the big, troublesome images (e.g. github-runner and gitlab-runner with nested docker) and confirmed this finally allowed us to skopeo copy ... directly from a local nix store on macOS to a container registry, just like on Linux.

This is huge for the community! Thanks @nlewo for your phenomenal work.

@nlewo
Copy link
Owner Author

nlewo commented Oct 30, 2022

@nktpro Nice, thx for your tests!
I'm still waiting for few more real life tests before merging this.

@nktpro
Copy link

nktpro commented Oct 31, 2022

Ugh, I just noticed there's a regression with copyToRoot, looks like it no longer merges all the paths together, e.g combining /bin from different packages.

For example:

nix2container.buildImage
{
  name = "netcat";
  tag = netcat.version;
  copyToRoot = [ dumb-init netcat bash ];
  config = {
    env = [
      "PATH=/bin"
    ];
    entrypoint = [ "dumb-init" "--" "nc" ];
  };
}

Will fail (on a typical Linux env) with:

The file '/bin' already exists in the tar with source path /nix/store/hx04v6jvr03kqw20ipyqfg63xv09mjpl-dumb-init-1.2.5/bin
but is added again with the source path /nix/store/529yr34pwqixjzna8j0f1zpp0x4r7bhg-libressl-3.5.3-nc/bin

@nlewo
Copy link
Owner Author

nlewo commented Nov 2, 2022

@nktpro it should be better now :)

@nktpro
Copy link

nktpro commented Nov 3, 2022

@nlewo I'm not sure which branch I should test again with that has the combined result of all your recent work?

The tar-graph branch still has the digest calculation issue on macOS, and the case-hack branch doesn't seem to have your latest fixes in the tar-graph branch?

@nlewo
Copy link
Owner Author

nlewo commented Nov 3, 2022 via email

@nktpro
Copy link

nktpro commented Nov 4, 2022

Thanks @nlewo, that did it. Happy to report that I found no other issue or regression at this point.

@blaggacao
Copy link
Contributor

blaggacao commented Nov 10, 2022

Unfortunately, it looks like testing this at work currently doesn't rally align with other urgencies. 😏

@nlewo
Copy link
Owner Author

nlewo commented Nov 11, 2022

@blaggacao Thx for the update. So, let's move forward then!

@nlewo nlewo merged commit 4cf5b9b into master Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants