Skip to content

Commit

Permalink
dockerTools: buildImage: image spec v1.2.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
lo1tuma committed Jul 24, 2017
1 parent 6589a83 commit ece4233
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
8 changes: 4 additions & 4 deletions doc/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@
<para>
<varname>pkgs.dockerTools</varname> is a set of functions for creating and
manipulating Docker images according to the
<link xlink:href="https://github.com/docker/docker/blob/master/image/spec/v1.md#docker-image-specification-v100">
Docker Image Specification v1.0.0
<link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#docker-image-specification-v120">
Docker Image Specification v1.2.0
</link>. Docker itself is not used to perform any of the operations done by these
functions.
</para>
Expand Down Expand Up @@ -493,8 +493,8 @@
<varname>config</varname> is used to specify the configuration of the
containers that will be started off the built image in Docker.
The available options are listed in the
<link xlink:href="https://github.com/docker/docker/blob/master/image/spec/v1.md#container-runconfig-field-descriptions">
Docker Image Specification v1.0.0
<link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions">
Docker Image Specification v1.2.0
</link>.
</para>
</callout>
Expand Down
19 changes: 19 additions & 0 deletions pkgs/build-support/docker/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,25 @@ rec {
# Use the temp folder we've been working on to create a new image.
mv temp image/$layerID
currentID=$layerID
imageJson=$(cat ${baseJson} | jshon -n "{}" -s layers -i type -n "[]" -i diff_ids -i rootfs -n "[]" -i history)
manifestJson=$(echo "[]" | jshon -n "{}" -n "[]" -s "$imageName:$imageTag" -i 0 -i RepoTags -n "[]" -i Layers -i 0)
while [[ -n "$currentID" ]]; do
layerChecksum=$(sha256sum image/$currentID/layer.tar | cut -d ' ' -f 1)
imageJson=$(echo "$imageJson" | jshon -e rootfs -e diff_ids -s "sha256:$layerChecksum" -i 0 -p -p)
imageJson=$(echo "$imageJson" | jshon -e history -n "{}" -s "1970-01-01T00:00:01Z" -i created -i 0 -p)
manifestJson=$(echo "$manifestJson" | jshon -e 0 -e Layers -s "$currentID/layer.tar" -i 0 -p -p)
currentID=$(cat image/$currentID/json | (jshon -e parent -u 2>/dev/null || true))
done
imageJsonChecksum=$(echo "$imageJson" | sha256sum | cut -d ' ' -f 1)
echo "$imageJson" > "image/$imageJsonChecksum.json"
manifestJson=$(echo "$manifestJson" | jshon -e 0 -s "$imageJsonChecksum.json" -i Config -p)
echo "$manifestJson" > "image/manifest.json"
# Store the json under the name image/repositories.
jshon -n object \
-n object -s "$layerID" -i "$imageTag" \
Expand Down

0 comments on commit ece4233

Please sign in to comment.