Use streamLayeredImage

[?]
Mar 22, 2023, 7:18 PM
HFOVEKSXBYXR73OGNSLY7WIOPW72ITQPKH4CYKRGBBBHKVPT2AUAC

Dependencies

Change contents

  • edit in 05-static-container/podman-devshell.nix at line 7
    [3.2427][3.2427:2628]()
    # Provides a fake "docker" binary mapping to podman
    dockerCompat = pkgs.runCommandNoCC "docker-podman-compat" {} ''
    mkdir -p $out/bin
    ln -s ${pkgs.podman}/bin/podman $out/bin/docker
    '';
  • edit in 05-static-container/podman-devshell.nix at line 17
    [3.3033][3.3033:3083]()
    dockerCompat # Aliases for docker / podman
  • replacement in 05-static-container/flake.nix at line 32
    [3.4082][3.4082:4143]()
    wttr-delft-container = pkgs.dockerTools.buildImage {
    [3.4082]
    [3.4143]
    # Actually, this makes a script that dumps the image to stdout,
    # in this way we can load the data directly into Podman, without
    # having a copy of the image in the Nix store; for large images this is very convenient!
    wttr-delft-container = pkgs.dockerTools.streamLayeredImage {
  • replacement in 05-static-container/demo.sh at line 13
    [3.5999][2.409:433]()
    h "Build the container"
    [3.5999]
    [3.6053]
    h "Build the container stream"
  • replacement in 05-static-container/demo.sh at line 16
    [3.6078][2.434:470](),[2.470][3.18:37](),[3.76][3.18:37]()
    n "It's a lot smaller than before!"
    x ls -lhH ./result
    [3.6078]
    [3.6104]
    n "The output is now a script:"
    x pygmentize -l bash ./result
  • replacement in 05-static-container/demo-inside-nix-develop.sh at line 12
    [3.6427][2.657:727](),[2.727][3.39:65](),[3.180][3.39:65]()
    h "We start by loading the container we just made into the registry:"
    x docker load -i ./result
    [3.6427]
    [3.6531]
    h "We start by loading the container stream we just made into the registry:"
    , "Just pipe it directly into podman"
    x "./result | podman load"
  • replacement in 05-static-container/demo-inside-nix-develop.sh at line 16
    [3.6532][2.728:770](),[3.61][3.6558:6611](),[2.770][3.6558:6611](),[3.6558][3.6558:6611]()
    h "We can see it's there, and it's tiny!"
    x "docker image ls | grep 'wttr-delft\|^REPOSITORY'"
    [3.6532]
    [3.6611]
    h "We can see the final image is there, and it's tiny!"
    x "podman image ls | grep 'wttr-delft\|^REPOSITORY'"
  • edit in 05-static-container/demo-inside-nix-develop.sh at line 19
    [3.6612]
    [2.771]
    , "Some more information is available:"
    x "podman inspect localhost/wttr-delft:nix | pygmentize -l json"
  • replacement in 05-static-container/demo-inside-nix-develop.sh at line 23
    [2.798][3.6637:6679](),[3.6637][3.6637:6679]()
    x docker run -it localhost/wttr-delft:nix
    [2.798]
    [3.6679]
    x "podman run -it localhost/wttr-delft:nix"