2018-10-26 07:23:30 -05:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
2019-11-07 09:36:40 -06:00
|
|
|
UBUNTU_BASE=0
|
|
|
|
|
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case "$1" in
|
|
|
|
"--ubuntu")
|
|
|
|
UBUNTU_BASE=1
|
|
|
|
echo "Ubuntu base image enabled"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
# unknown param causes args to be passed through to $@
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2018-11-20 10:00:20 -06:00
|
|
|
_raw_grafana_tag=$1
|
2018-10-26 07:23:30 -05:00
|
|
|
_docker_repo=${2:-grafana/grafana-enterprise}
|
|
|
|
|
2018-11-20 10:00:20 -06:00
|
|
|
if echo "$_raw_grafana_tag" | grep -q "^v"; then
|
|
|
|
_grafana_tag=$(echo "${_raw_grafana_tag}" | cut -d "v" -f 2)
|
2020-02-07 09:08:14 -06:00
|
|
|
elif echo "$_raw_grafana_tag" | grep -q "^master-"; then
|
|
|
|
_grafana_tag="master"
|
2018-11-20 10:00:20 -06:00
|
|
|
else
|
|
|
|
_grafana_tag="${_raw_grafana_tag}"
|
|
|
|
fi
|
|
|
|
|
2019-11-07 09:36:40 -06:00
|
|
|
if [ ${UBUNTU_BASE} = "0" ]; then
|
|
|
|
TAG_SUFFIX=""
|
|
|
|
DOCKERFILE="Dockerfile"
|
|
|
|
else
|
|
|
|
TAG_SUFFIX="-ubuntu"
|
2019-11-21 11:05:26 -06:00
|
|
|
DOCKERFILE="ubuntu.Dockerfile"
|
2019-11-07 09:36:40 -06:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Building and deploying ${_docker_repo}:${_grafana_tag}${TAG_SUFFIX}"
|
2018-11-20 10:00:20 -06:00
|
|
|
|
2018-10-26 07:23:30 -05:00
|
|
|
docker build \
|
2019-11-07 09:36:40 -06:00
|
|
|
--tag "${_docker_repo}:${_grafana_tag}${TAG_SUFFIX}" \
|
2018-10-26 07:23:30 -05:00
|
|
|
--no-cache=true \
|
2019-11-07 09:36:40 -06:00
|
|
|
-f ${DOCKERFILE} \
|
2018-10-26 07:23:30 -05:00
|
|
|
.
|
2018-10-31 10:02:27 -05:00
|
|
|
|
2019-11-07 09:36:40 -06:00
|
|
|
docker push "${_docker_repo}:${_grafana_tag}${TAG_SUFFIX}"
|
2018-12-04 03:49:29 -06:00
|
|
|
|
|
|
|
if echo "$_raw_grafana_tag" | grep -q "^v" && echo "$_raw_grafana_tag" | grep -qv "beta"; then
|
2019-11-07 09:36:40 -06:00
|
|
|
docker tag "${_docker_repo}:${_grafana_tag}${TAG_SUFFIX}" "${_docker_repo}:latest${TAG_SUFFIX}"
|
|
|
|
docker push "${_docker_repo}:latest${TAG_SUFFIX}"
|
2018-12-04 03:49:29 -06:00
|
|
|
fi
|
2020-02-07 09:08:14 -06:00
|
|
|
|
|
|
|
|
|
|
|
if echo "${_raw_grafana_tag}" | grep -q "^master-" && [ ${UBUNTU_BASE} = "1" ]; then
|
|
|
|
docker tag "${_docker_repo}:${_grafana_tag}${TAG_SUFFIX}" "grafana/grafana-enterprise-dev:${_raw_grafana_tag}"
|
|
|
|
docker push "grafana/grafana-enterprise-dev:${_raw_grafana_tag}"
|
|
|
|
fi
|
|
|
|
|