diff options
author | Alex James <git@alextjam.es> | 2022-08-15 23:09:42 -0500 |
---|---|---|
committer | Alex James <git@alextjam.es> | 2022-08-16 21:47:29 -0500 |
commit | c9af8982551f903e634084b35b2597c98beed0ab (patch) | |
tree | 3ed46595495bbf95fac9f0c3ca85e93264b7b57a /pkgs/build-support/docker/default.nix | |
parent | ac4721c5f88db1b7e4f087a1f7c7c261d6fe8ec8 (diff) | |
download | nixpkgs-c9af8982551f903e634084b35b2597c98beed0ab.tar nixpkgs-c9af8982551f903e634084b35b2597c98beed0ab.tar.gz nixpkgs-c9af8982551f903e634084b35b2597c98beed0ab.tar.bz2 nixpkgs-c9af8982551f903e634084b35b2597c98beed0ab.tar.lz nixpkgs-c9af8982551f903e634084b35b2597c98beed0ab.tar.xz nixpkgs-c9af8982551f903e634084b35b2597c98beed0ab.tar.zst nixpkgs-c9af8982551f903e634084b35b2597c98beed0ab.zip |
dockerTools.buildImage: make VM memSize configurable
Fixes #186752. This adds buildVMMemorySize (defaults to 512 MiB) to buildImage, which is passed to vm.runInLinuxVM. This is needed for larger base images, which may otherwise cause container build failures due to OOM in the VM.
Diffstat (limited to 'pkgs/build-support/docker/default.nix')
-rw-r--r-- | pkgs/build-support/docker/default.nix | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix index 39008df74f1..7468f056005 100644 --- a/pkgs/build-support/docker/default.nix +++ b/pkgs/build-support/docker/default.nix @@ -205,6 +205,7 @@ rec { , fromImageName ? null , fromImageTag ? null , diskSize ? 1024 + , buildVMMemorySize ? 512 , preMount ? "" , postMount ? "" , postUmount ? "" @@ -218,6 +219,7 @@ rec { destination = "./image"; }; inherit fromImage fromImageName fromImageTag; + memSize = buildVMMemorySize; nativeBuildInputs = [ util-linux e2fsprogs jshon rsync jq ]; } '' @@ -407,6 +409,8 @@ rec { fromImageTag ? null , # How much disk to allocate for the temporary virtual machine. diskSize ? 1024 + , # How much memory to allocate for the temporary virtual machine. + buildVMMemorySize ? 512 , # Commands (bash) to run on the layer; these do not require sudo. extraCommands ? "" }: @@ -418,7 +422,7 @@ rec { runWithOverlay { name = "docker-layer-${name}"; - inherit fromImage fromImageName fromImageTag diskSize; + inherit fromImage fromImageName fromImageTag diskSize buildVMMemorySize; preMount = lib.optionalString (copyToRoot != null && copyToRoot != [ ]) '' echo "Adding contents..." @@ -517,6 +521,8 @@ rec { runAsRoot ? null , # Size of the virtual machine disk to provision when building the image. diskSize ? 1024 + , # Size of the virtual machine memory to provision when building the image. + buildVMMemorySize ? 512 , # Time of creation of the image. created ? "1970-01-01T00:00:01Z" , # Deprecated. @@ -563,7 +569,7 @@ rec { mkRootLayer { name = baseName; inherit baseJson fromImage fromImageName fromImageTag - keepContentsDirlinks runAsRoot diskSize + keepContentsDirlinks runAsRoot diskSize buildVMMemorySize extraCommands; copyToRoot = rootContents; }; |