Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a bundle of all docker-images in a composition. #132

Open
tomprince opened this issue Aug 27, 2021 · 1 comment
Open

Expose a bundle of all docker-images in a composition. #132

tomprince opened this issue Aug 27, 2021 · 1 comment

Comments

@tomprince
Copy link
Contributor

I'm using arion to build docker-compose configuration for running on a non-nix-based system. I'd like to be able get a single file with all the needed docker images (such as is made be dockerTools.mergeImages.

I'm currently using:

let
arion = pkgs.arion.eval { ... };
in pkgs.dockerTools.mergeImages (
  map (
    { imageName, imageTag, imageExe }:
    pkgs.runCommand "${baseNameOf imageName}.tar.gz"
      {
        inherit imageName;
        passthru = { inherit imageTag; };
        nativeBuildInputs = [ pkgs.pigz ];
      } "${imageExe} | pigz -nT > $out"
    ) arion.config.build.imagesToLoad
)

to build one. (Unfortunately, mergeImages doesn't support streamed images, so I needed to reimplement buildLayerdImage).

@roberth
Copy link
Member

roberth commented Aug 28, 2021

I think the most significant part of solving this is to improve dockerTools to add a streaming mergeImages, but the glue can also be improved on the arion side.

The info to do this is already available in the x-arion field.

examples/full-nixos$ ../../run-arion-quick cat | jq '."x-arion".images'
[
  {
    "imageExe": "/nix/store/371w0nm23r6a6kmpncz8q5kvqpks74qh-stream-webserver",
    "imageName": "webserver",
    "imageTag": "5r4gm8i0wfpggzw8bygmzfmsw45arcd3"
  }
]

But you don't have to process this information externally. You could write a module instead, that you import at the arion project level (top level of arion-compose.nix). This module can write to config.docker-compose.extended, so you can extract it with arion cat | jq '."x-arion".loadImagesScript'. I suppose it would be nice if arion cat could select the option by itself, so you don't have to worry about jq and the compose file internals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants