Hey!
I have Nix to pull a prebuilt image, and I want to remove an unused directory from that image to make the image smaller, currently I am doing something like:
base_image = pkgs.dockerTools.pullImage {
imageName = "base";
...
};
image = pkgs.dockerTools.buildLayeredImage {
name = "image";
tag = "...";
fromImage = base_image;
maxLayers = ...;
created = ...;
contents = with pkgs.pkgsLinux; [
curl
];
extraCommands = ''
// other commands
...
// to remove the directory
rm -rf ./directory/to/remove
'';
};
But this doesn’t work because extraCommands only executes on the top layer without access to other layers (i.e. layers with the docker image). When I do this it does nothing because ./directory/to/remove
is not on the file system on the top layer.
Is there a way or walk around to remove something during build time?