Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

dockerTools: optionally preserve directory symlinks

In some cases, this seems to save a lot (>40%) of space.

(cherry picked from commit dce2c258ac33ee1cd3b3e852b36e1d8fa11f33a1)

authored by Ryan Trinkle and committed by John Ericson 2a17d7ca e08245f8

+17 -4
+17 -4
pkgs/build-support/docker/default.nix
··· 249 baseJson, 250 # Files to add to the layer. 251 contents ? null, 252 # Additional commands to run on the layer before it is tar'd up. 253 extraCommands ? "", uid ? 0, gid ? 0 254 }: ··· 262 echo "Adding contents..." 263 for item in $contents; do 264 echo "Adding $item" 265 - rsync -ak --chown=0:0 $item/ layer/ 266 done 267 else 268 echo "No contents to add to layer." ··· 303 runAsRoot, 304 # Files to add to the layer. If null, an empty layer will be created. 305 contents ? null, 306 # JSON containing configuration and metadata for this layer. 307 baseJson, 308 # Existing image onto which to append the new layer. ··· 327 echo "Adding contents..." 328 for item in ${toString contents}; do 329 echo "Adding $item..." 330 - rsync -ak --chown=0:0 $item/ layer/ 331 done 332 333 chmod ug+w layer ··· 391 fromImageTag ? null, 392 # Files to put on the image (a nix store path or list of paths). 393 contents ? null, 394 # Docker config; e.g. what command to run on the container. 395 config ? null, 396 # Optional bash script to run on the files prior to fixturizing the layer. ··· 417 if runAsRoot == null 418 then mkPureLayer { 419 name = baseName; 420 - inherit baseJson contents extraCommands uid gid; 421 } else mkRootLayer { 422 name = baseName; 423 inherit baseJson fromImage fromImageName fromImageTag 424 - contents runAsRoot diskSize extraCommands; 425 }; 426 result = runCommand "docker-image-${baseName}.tar.gz" { 427 buildInputs = [ jshon pigz coreutils findutils jq ];
··· 249 baseJson, 250 # Files to add to the layer. 251 contents ? null, 252 + # When copying the contents into the image, preserve symlinks to 253 + # directories (see `rsync -K`). Otherwise, transform those symlinks 254 + # into directories. 255 + keepContentsDirlinks ? false, 256 # Additional commands to run on the layer before it is tar'd up. 257 extraCommands ? "", uid ? 0, gid ? 0 258 }: ··· 266 echo "Adding contents..." 267 for item in $contents; do 268 echo "Adding $item" 269 + rsync -a${if keepContentsDirlinks then "K" else "k"} --chown=0:0 $item/ layer/ 270 done 271 else 272 echo "No contents to add to layer." ··· 307 runAsRoot, 308 # Files to add to the layer. If null, an empty layer will be created. 309 contents ? null, 310 + # When copying the contents into the image, preserve symlinks to 311 + # directories (see `rsync -K`). Otherwise, transform those symlinks 312 + # into directories. 313 + keepContentsDirlinks ? false, 314 # JSON containing configuration and metadata for this layer. 315 baseJson, 316 # Existing image onto which to append the new layer. ··· 335 echo "Adding contents..." 336 for item in ${toString contents}; do 337 echo "Adding $item..." 338 + rsync -a${if keepContentsDirlinks then "K" else "k"} --chown=0:0 $item/ layer/ 339 done 340 341 chmod ug+w layer ··· 399 fromImageTag ? null, 400 # Files to put on the image (a nix store path or list of paths). 401 contents ? null, 402 + # When copying the contents into the image, preserve symlinks to 403 + # directories (see `rsync -K`). Otherwise, transform those symlinks 404 + # into directories. 405 + keepContentsDirlinks ? false, 406 # Docker config; e.g. what command to run on the container. 407 config ? null, 408 # Optional bash script to run on the files prior to fixturizing the layer. ··· 429 if runAsRoot == null 430 then mkPureLayer { 431 name = baseName; 432 + inherit baseJson contents keepContentsDirlinks extraCommands uid gid; 433 } else mkRootLayer { 434 name = baseName; 435 inherit baseJson fromImage fromImageName fromImageTag 436 + contents keepContentsDirlinks runAsRoot diskSize 437 + extraCommands; 438 }; 439 result = runCommand "docker-image-${baseName}.tar.gz" { 440 buildInputs = [ jshon pigz coreutils findutils jq ];