From e007eb480c6041fd98b8f9e53bdac2ba82e4648c Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Fri, 1 Jul 2022 15:02:00 +0200 Subject: dockerTools.buildImage: Add copyToRoot to replace contents, explain usage --- doc/builders/images/dockertools.section.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/builders/images/dockertools.section.md b/doc/builders/images/dockertools.section.md index d7f8741437cc9..2a41d48cf1340 100644 --- a/doc/builders/images/dockertools.section.md +++ b/doc/builders/images/dockertools.section.md @@ -20,7 +20,12 @@ buildImage { fromImageName = null; fromImageTag = "latest"; - contents = pkgs.redis; + copyToRoot = pkgs.buildEnv { + name = "image-root"; + paths = [ pkgs.redis ]; + pathsToLink = [ "/bin" ]; + }; + runAsRoot = '' #!${pkgs.runtimeShell} mkdir -p /data @@ -46,7 +51,7 @@ The above example will build a Docker image `redis/latest` from the given base i - `fromImageTag` can be used to further specify the tag of the base image within the repository, in case an image contains multiple tags. By default it's `null`, in which case `buildImage` will peek the first tag available for the base image. -- `contents` is a derivation that will be copied in the new layer of the resulting image. This can be similarly seen as `ADD contents/ /` in a `Dockerfile`. By default it's `null`. +- `copyToRoot` is a derivation that will be copied in the new layer of the resulting image. This can be similarly seen as `ADD contents/ /` in a `Dockerfile`. By default it's `null`. - `runAsRoot` is a bash script that will run as root in an environment that overlays the existing layers of the base image with the new resulting layer, including the previously copied `contents` derivation. This can be similarly seen as `RUN ...` in a `Dockerfile`. @@ -81,7 +86,11 @@ pkgs.dockerTools.buildImage { name = "hello"; tag = "latest"; created = "now"; - contents = pkgs.hello; + copyToRoot = pkgs.buildEnv { + name = "image-root"; + paths = [ pkgs.hello ]; + pathsToLink = [ "/bin" ]; + }; config.Cmd = [ "/bin/hello" ]; } -- cgit 1.4.1