grafana/packaging/docker/build-enterprise.sh

51 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/sh
set -e
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
_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)
else
_grafana_tag="${_raw_grafana_tag}"
fi
if [ ${UBUNTU_BASE} = "0" ]; then
TAG_SUFFIX=""
DOCKERFILE="Dockerfile"
else
TAG_SUFFIX="-ubuntu"
DOCKERFILE="ubuntu.Dockerfile"
fi
echo "Building and deploying ${_docker_repo}:${_grafana_tag}${TAG_SUFFIX}"
2018-11-20 10:00:20 -06:00
docker build \
--tag "${_docker_repo}:${_grafana_tag}${TAG_SUFFIX}" \
--no-cache=true \
-f ${DOCKERFILE} \
.
docker push "${_docker_repo}:${_grafana_tag}${TAG_SUFFIX}"
if echo "$_raw_grafana_tag" | grep -q "^v" && echo "$_raw_grafana_tag" | grep -qv "beta"; then
docker tag "${_docker_repo}:${_grafana_tag}${TAG_SUFFIX}" "${_docker_repo}:latest${TAG_SUFFIX}"
docker push "${_docker_repo}:latest${TAG_SUFFIX}"
fi