diff options
author | Robert Hensing <roberth@users.noreply.github.com> | 2020-07-16 17:05:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-16 17:05:58 +0200 |
commit | c1908bf802846be5342bc340706819e7adc8dded (patch) | |
tree | d1f05d5e47a8842ca5205f38f223e5e871c16dfa /pkgs/build-support | |
parent | 5e1d1418095bc1faf910914eee81effad070b0bc (diff) | |
parent | 8c0459f6118a7021acad0d07eeece08c0d9bd87b (diff) |
Merge pull request #92934 from hercules-ci/dockerTools-set-imageTag
dockerTools: Always set imageTag attribute
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/docker/default.nix | 12 | ||||
-rw-r--r-- | pkgs/build-support/docker/examples.nix | 18 |
2 files changed, 30 insertions, 0 deletions
diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix index 7ff325382a6b5..bf815af6f7c02 100644 --- a/pkgs/build-support/docker/default.nix +++ b/pkgs/build-support/docker/default.nix @@ -442,6 +442,7 @@ rec { in runCommand "${name}.tar.gz" { inherit (stream) imageName; + passthru = { inherit (stream) imageTag; }; buildInputs = [ pigz ]; } "${stream} | pigz -nT > $out"; @@ -517,6 +518,11 @@ rec { layerClosure = writeReferencesToFile layer; passthru.buildArgs = args; passthru.layer = layer; + passthru.imageTag = + if tag != null + then lib.toLower tag + else + lib.head (lib.strings.splitString "-" (baseNameOf result.outPath)); # Docker can't be made to run darwin binaries meta.badPlatforms = lib.platforms.darwin; } '' @@ -737,6 +743,11 @@ rec { conf = runCommand "${name}-conf.json" { inherit maxLayers created; imageName = lib.toLower name; + passthru.imageTag = + if tag != null + then tag + else + lib.head (lib.strings.splitString "-" (baseNameOf conf.outPath)); paths = referencesByPopularity overallClosure; buildInputs = [ jq ]; } '' @@ -792,6 +803,7 @@ rec { ''; result = runCommand "stream-${name}" { inherit (conf) imageName; + passthru = { inherit (conf) imageTag; }; buildInputs = [ makeWrapper ]; } '' makeWrapper ${streamScript} $out --add-flags ${conf} diff --git a/pkgs/build-support/docker/examples.nix b/pkgs/build-support/docker/examples.nix index 81dae9b612411..0d907c2d64bf2 100644 --- a/pkgs/build-support/docker/examples.nix +++ b/pkgs/build-support/docker/examples.nix @@ -364,4 +364,22 @@ rec { created = "now"; }; + # buildImage without explicit tag + bashNoTag = pkgs.dockerTools.buildImage { + name = "bash-no-tag"; + contents = pkgs.bashInteractive; + }; + + # buildLayeredImage without explicit tag + bashNoTagLayered = pkgs.dockerTools.buildLayeredImage { + name = "bash-no-tag-layered"; + contents = pkgs.bashInteractive; + }; + + # buildImage without explicit tag + bashNoTagStreamLayered = pkgs.dockerTools.streamLayeredImage { + name = "bash-no-tag-stream-layered"; + contents = pkgs.bashInteractive; + }; + } |