mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-10-02 18:47:58 +03:00
Merge pull request #186896 from al3xtjames/dockertools-buildimage-memsize
dockerTools.buildImage: make memSize configurable
This commit is contained in:
commit
4b3b52974b
@ -36,6 +36,9 @@ buildImage {
|
|||||||
WorkingDir = "/data";
|
WorkingDir = "/data";
|
||||||
Volumes = { "/data" = { }; };
|
Volumes = { "/data" = { }; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
diskSize = 1024;
|
||||||
|
buildVMMemorySize = 512;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -59,6 +62,10 @@ The above example will build a Docker image `redis/latest` from the given base i
|
|||||||
|
|
||||||
- `config` is used to specify the configuration of the containers that will be started off the built image in Docker. The available options are listed in the [Docker Image Specification v1.2.0](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions).
|
- `config` is used to specify the configuration of the containers that will be started off the built image in Docker. The available options are listed in the [Docker Image Specification v1.2.0](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions).
|
||||||
|
|
||||||
|
- `diskSize` is used to specify the disk size of the VM used to build the image in megabytes. By default it's 1024 MiB.
|
||||||
|
|
||||||
|
- `buildVMMemorySize` is used to specify the memory size of the VM to build the image in megabytes. By default it's 512 MiB.
|
||||||
|
|
||||||
After the new layer has been created, its closure (to which `contents`, `config` and `runAsRoot` contribute) will be copied in the layer itself. Only new dependencies that are not already in the existing layers will be copied.
|
After the new layer has been created, its closure (to which `contents`, `config` and `runAsRoot` contribute) will be copied in the layer itself. Only new dependencies that are not already in the existing layers will be copied.
|
||||||
|
|
||||||
At the end of the process, only one new single layer will be produced and added to the resulting image.
|
At the end of the process, only one new single layer will be produced and added to the resulting image.
|
||||||
|
@ -205,6 +205,7 @@ rec {
|
|||||||
, fromImageName ? null
|
, fromImageName ? null
|
||||||
, fromImageTag ? null
|
, fromImageTag ? null
|
||||||
, diskSize ? 1024
|
, diskSize ? 1024
|
||||||
|
, buildVMMemorySize ? 512
|
||||||
, preMount ? ""
|
, preMount ? ""
|
||||||
, postMount ? ""
|
, postMount ? ""
|
||||||
, postUmount ? ""
|
, postUmount ? ""
|
||||||
@ -218,6 +219,7 @@ rec {
|
|||||||
destination = "./image";
|
destination = "./image";
|
||||||
};
|
};
|
||||||
inherit fromImage fromImageName fromImageTag;
|
inherit fromImage fromImageName fromImageTag;
|
||||||
|
memSize = buildVMMemorySize;
|
||||||
|
|
||||||
nativeBuildInputs = [ util-linux e2fsprogs jshon rsync jq ];
|
nativeBuildInputs = [ util-linux e2fsprogs jshon rsync jq ];
|
||||||
} ''
|
} ''
|
||||||
@ -407,6 +409,8 @@ rec {
|
|||||||
fromImageTag ? null
|
fromImageTag ? null
|
||||||
, # How much disk to allocate for the temporary virtual machine.
|
, # How much disk to allocate for the temporary virtual machine.
|
||||||
diskSize ? 1024
|
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.
|
, # Commands (bash) to run on the layer; these do not require sudo.
|
||||||
extraCommands ? ""
|
extraCommands ? ""
|
||||||
}:
|
}:
|
||||||
@ -418,7 +422,7 @@ rec {
|
|||||||
runWithOverlay {
|
runWithOverlay {
|
||||||
name = "docker-layer-${name}";
|
name = "docker-layer-${name}";
|
||||||
|
|
||||||
inherit fromImage fromImageName fromImageTag diskSize;
|
inherit fromImage fromImageName fromImageTag diskSize buildVMMemorySize;
|
||||||
|
|
||||||
preMount = lib.optionalString (copyToRoot != null && copyToRoot != [ ]) ''
|
preMount = lib.optionalString (copyToRoot != null && copyToRoot != [ ]) ''
|
||||||
echo "Adding contents..."
|
echo "Adding contents..."
|
||||||
@ -517,6 +521,8 @@ rec {
|
|||||||
runAsRoot ? null
|
runAsRoot ? null
|
||||||
, # Size of the virtual machine disk to provision when building the image.
|
, # Size of the virtual machine disk to provision when building the image.
|
||||||
diskSize ? 1024
|
diskSize ? 1024
|
||||||
|
, # Size of the virtual machine memory to provision when building the image.
|
||||||
|
buildVMMemorySize ? 512
|
||||||
, # Time of creation of the image.
|
, # Time of creation of the image.
|
||||||
created ? "1970-01-01T00:00:01Z"
|
created ? "1970-01-01T00:00:01Z"
|
||||||
, # Deprecated.
|
, # Deprecated.
|
||||||
@ -563,7 +569,7 @@ rec {
|
|||||||
mkRootLayer {
|
mkRootLayer {
|
||||||
name = baseName;
|
name = baseName;
|
||||||
inherit baseJson fromImage fromImageName fromImageTag
|
inherit baseJson fromImage fromImageName fromImageTag
|
||||||
keepContentsDirlinks runAsRoot diskSize
|
keepContentsDirlinks runAsRoot diskSize buildVMMemorySize
|
||||||
extraCommands;
|
extraCommands;
|
||||||
copyToRoot = rootContents;
|
copyToRoot = rootContents;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user