-
Notifications
You must be signed in to change notification settings - Fork 352
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
Being able to build smaller containers #1367
Comments
Fully agreed, someone needs to look into container.nix and expose a knob to disable the layering. |
I don't think those packages you name can be the culprit. They have really small closures! Together they're probably only like 100 MiB. Something weirder is going on. |
Co-authored-by: Jörg Thalheim <[email protected]>
I was having the same issue when trying to build a production container which includes a simple binary produced by My reference use case:
Immediate problems not (yet) solved with
To reduce the size of the container image I already did the following: packages = with pkgs; lib.optionals (!config.container.isBuilding) [gnumake go-swagger gopls nix-prefetch];
languages.go.enable = !config.container.isBuilding;
copyToRoot = [(pkgs.callPackage ./pdnsupdate.nix {})]; which produces a If I use the above remove container tooling mod, I get a marginally better result ( I'm not at all familiar with Also the container functionality forces using |
I think the bigger issue is that we're using the usual
Yeah, that's in line with what I expected. I think it's clear that the main issue is not the extra tools added to the containers by default, or even the particular tools used to generate the container images. The issue is that the containers are based on the shells, but more crucially that the shells have fat closures. The shells have big closures because they're normal devShells created with Nixpkgs There's a WIP PR in Nixpkgs that introduces a distinction between 'build shells' (shells automatically derived from a derivation and which assume you want build-time tools associated with included packages, like the devShells produced by Short of waiting for that PR, depending on it now, or otherwise hoping that it meets our needs, we could choose either to handle devenv's One consideration is that we kind of depend on the 'build shell' behavior for our interfaces for including language-specific packages-- this is why, for instance, one can just put their environment's Python libs into Should we do an experiment against that WIP Nixpkgs PR and see (a) if, using that instead of I'd be down to try that if someone wants to provide a sample project where their containers/shells normally come out bigger than necessary. |
@therealpxc Thanks for your comment, I actually didn't figure out that If no one does, I can have a try this week-end. |
See #1415 |
Actually, IIRC, I have made some progress, so that, when |
Fantastic, I hope I find some time to try that sometime next week! |
I'm trying to define some simple containers:
blue
being a haskell.nix derivationIt creates a first layer with my derivation (~420MiB) and adds a layer with many things (coreutils-full, bashInteractive, su, etc.) which weight 15 GiB.
We should be able to passe the final derivation, or to disable extra layers.
The text was updated successfully, but these errors were encountered: