mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-28 22:32:58 +03:00
dockerTools.buildImage: add option to use nix output hash as tag
This commit is contained in:
parent
588dbd714e
commit
39e678e24e
@ -521,7 +521,7 @@ merge:"diff3"
|
|||||||
<callout arearefs='ex-dockerTools-buildImage-2'>
|
<callout arearefs='ex-dockerTools-buildImage-2'>
|
||||||
<para>
|
<para>
|
||||||
<varname>tag</varname> specifies the tag of the resulting image. By
|
<varname>tag</varname> specifies the tag of the resulting image. By
|
||||||
default it's <literal>latest</literal>.
|
default it's <literal>null</literal>, which indicates that the nix output hash will be used as tag.
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
<callout arearefs='ex-dockerTools-buildImage-3'>
|
<callout arearefs='ex-dockerTools-buildImage-3'>
|
||||||
|
@ -127,6 +127,12 @@ $ nix-instantiate -E '(import <nixpkgsunstable> {}).gitFull'
|
|||||||
Make sure the key file is accessible to the daemon.
|
Make sure the key file is accessible to the daemon.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<varname>dockerTools.buildImage</varname> now uses <literal>null</literal> as default value for <varname>tag</varname>,
|
||||||
|
which indicates that the nix output hash will be used as tag.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -420,8 +420,8 @@ rec {
|
|||||||
buildImage = args@{
|
buildImage = args@{
|
||||||
# Image name.
|
# Image name.
|
||||||
name,
|
name,
|
||||||
# Image tag.
|
# Image tag, when null then the nix output hash will be used.
|
||||||
tag ? "latest",
|
tag ? null,
|
||||||
# Parent image, to append to.
|
# Parent image, to append to.
|
||||||
fromImage ? null,
|
fromImage ? null,
|
||||||
# Name of the parent image; will be read from the image otherwise.
|
# Name of the parent image; will be read from the image otherwise.
|
||||||
@ -471,12 +471,19 @@ rec {
|
|||||||
buildInputs = [ jshon pigz coreutils findutils jq ];
|
buildInputs = [ jshon pigz coreutils findutils jq ];
|
||||||
# Image name and tag must be lowercase
|
# Image name and tag must be lowercase
|
||||||
imageName = lib.toLower name;
|
imageName = lib.toLower name;
|
||||||
imageTag = lib.toLower tag;
|
imageTag = if tag == null then "" else lib.toLower tag;
|
||||||
inherit fromImage baseJson;
|
inherit fromImage baseJson;
|
||||||
layerClosure = writeReferencesToFile layer;
|
layerClosure = writeReferencesToFile layer;
|
||||||
passthru.buildArgs = args;
|
passthru.buildArgs = args;
|
||||||
passthru.layer = layer;
|
passthru.layer = layer;
|
||||||
} ''
|
} ''
|
||||||
|
${lib.optionalString (tag == null) ''
|
||||||
|
outName="$(basename "$out")"
|
||||||
|
outHash=$(echo "$outName" | cut -d - -f 1)
|
||||||
|
|
||||||
|
imageTag=$outHash
|
||||||
|
''}
|
||||||
|
|
||||||
# Print tar contents:
|
# Print tar contents:
|
||||||
# 1: Interpreted as relative to the root directory
|
# 1: Interpreted as relative to the root directory
|
||||||
# 2: With no trailing slashes on directories
|
# 2: With no trailing slashes on directories
|
||||||
|
Loading…
Reference in New Issue
Block a user