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

* container-image-tags:
  build: Tag container images with git branch/sha build information

Signed-off-by: Jared Tobin <jared@tlon.io>
This commit is contained in:
Jared Tobin 2019-10-05 22:32:33 +04:00
commit b85936ee5c
No known key found for this signature in database
GPG Key ID: 0E4647D58F8A69E4

View File

@ -12,12 +12,22 @@ say() {
echo "$1" >&2
}
git_sha="$(git rev-parse HEAD)"
git_sha="${git_sha:0:8}"
git_branch="$(git branch --show-current)"
git_tag="${build}:${git_branch}-${git_sha}"
say "Building $build..."
image="$(nix-build default.nix --no-out-link -A $build)"
say "Loading $image into Docker..."
tag="$(docker load --quiet --input $image)"
tag="${tag#Loaded image: }"
nix_tag="$(docker load --quiet --input $image)"
nix_tag="${nix_tag#Loaded image: }"
say "Re-tagging with current git branch:$git_branch SHA:$git_sha"
docker tag $nix_tag $git_tag
# Output only the tag on stdout for subsequent pipes/tooling.
echo $tag
echo $git_tag