Merge branch 'container-image-tags' (#1800)

* container-image-tags:
  build: Trimming build target from container image tag

Signed-off-by: Jared Tobin <jared@tlon.io>
This commit is contained in:
Jared Tobin 2019-10-07 09:34:26 +04:00
commit c3a69d683b
No known key found for this signature in database
GPG Key ID: 0E4647D58F8A69E4

View File

@ -17,17 +17,19 @@ git_sha="${git_sha:0:8}"
git_branch="$(git branch --show-current)"
git_tag="${build}:${git_branch}-${git_sha}"
git_tag="${git_branch}-${git_sha}"
say "Building $build..."
image="$(nix-build default.nix --no-out-link -A $build)"
nix_out="$(nix-build default.nix --no-out-link -A $build)"
say "Loading $image into Docker..."
nix_tag="$(docker load --quiet --input $image)"
nix_tag="${nix_tag#Loaded image: }"
say "Loading $nix_out into Docker..."
nix_name="$(docker load --quiet --input $nix_out)"
nix_name="${nix_name#Loaded image: }"
say "Re-tagging with current git branch:$git_branch SHA:$git_sha"
docker tag $nix_tag $git_tag
say "Re-tagging with current git branch:$git_branch and SHA:$git_sha"
image_repo="$(docker images $nix_name --format '{{.Repository}}')"
image_name="${image_repo}:${git_tag}"
docker tag $nix_name $image_name
# Output only the tag on stdout for subsequent pipes/tooling.
echo $git_tag
echo $image_name