#!/bin/bash

# Builds (or pulls) our go-deps docker image.

set -eu

if [ $# -ne 0 ]; then
    echo "no arguments allowed for $(basename $0), given: $@" >&2
    exit 64
fi

bindir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

. $bindir/_docker.sh
. $bindir/_tag.sh

tag=$(go_deps_sha)

if (docker_pull go-deps "${tag}"); then
    echo "$(docker_repo go-deps):${tag}"
else
    rootdir="$( cd $bindir/.. && pwd )"
    docker_build go-deps "${tag}" $rootdir/Dockerfile-go-deps
fi
