Commit ff47238b by Arve Knudsen Committed by GitHub

Build: Build Ubuntu based Docker images also for ARM (#20267)

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent fa91462d
......@@ -3,6 +3,7 @@ set -e
BUILD_FAST=0
UBUNTU_BASE=0
TAG_SUFFIX=""
while [ "$1" != "" ]; do
case "$1" in
......@@ -13,6 +14,7 @@ while [ "$1" != "" ]; do
;;
"--ubuntu")
UBUNTU_BASE=1
TAG_SUFFIX="-ubuntu"
echo "Ubuntu base image enabled"
shift
;;
......@@ -33,20 +35,40 @@ else
_grafana_version=$_grafana_tag
fi
if [ $UBUNTU_BASE = "0" ]; then
echo "Building ${_docker_repo}:${_grafana_version}"
else
echo "Building ${_docker_repo}:${_grafana_version}-ubuntu"
fi
echo "Building ${_docker_repo}:${_grafana_version}${TAG_SUFFIX}"
export DOCKER_CLI_EXPERIMENTAL=enabled
# Build grafana image for a specific arch
docker_build () {
base_image=$1
grafana_tgz=$2
tag=$3
dockerfile=${4:-Dockerfile}
arch=$1
case "$arch" in
"x64")
base_arch=""
repo_arch=""
;;
"armv7")
base_arch="arm32v7/"
repo_arch="-arm32v7-linux"
;;
"arm64")
base_arch="arm64v8/"
repo_arch="-arm64v8-linux"
;;
esac
if [ $UBUNTU_BASE = "0" ]; then
libc="-musl"
dockerfile="Dockerfile"
base_image="${base_arch}alpine:3.10"
else
libc=""
dockerfile="Dockerfile.ubuntu"
base_image="${base_arch}ubuntu:18.10"
fi
grafana_tgz="grafana-latest.linux-${arch}${libc}.tar.gz"
tag="${_docker_repo}${repo_arch}:${_grafana_version}${TAG_SUFFIX}"
docker build \
--build-arg BASE_IMAGE=${base_image} \
......@@ -58,48 +80,34 @@ docker_build () {
}
docker_tag_linux_amd64 () {
repo=$1
tag=$2
docker tag "${_docker_repo}:${_grafana_version}" "${repo}:${tag}"
tag=$1
docker tag "${_docker_repo}:${_grafana_version}${TAG_SUFFIX}" "${_docker_repo}:${tag}${TAG_SUFFIX}"
}
# Tag docker images of all architectures
docker_tag_all () {
repo=$1
tag=$2
docker_tag_linux_amd64 $1 $2
tag=$1
docker_tag_linux_amd64 $1
if [ $BUILD_FAST = "0" ]; then
docker tag "${_docker_repo}-arm32v7-linux:${_grafana_version}" "${repo}-arm32v7-linux:${tag}"
docker tag "${_docker_repo}-arm64v8-linux:${_grafana_version}" "${repo}-arm64v8-linux:${tag}"
docker tag "${_docker_repo}-arm32v7-linux:${_grafana_version}${TAG_SUFFIX}"
"${_docker_repo}-arm32v7-linux:${tag}${TAG_SUFFIX}"
docker tag "${_docker_repo}-arm64v8-linux:${_grafana_version}${TAG_SUFFIX}"
"${_docker_repo}-arm64v8-linux:${tag}${TAG_SUFFIX}"
fi
}
if [ $UBUNTU_BASE = "0" ]; then
docker_build "alpine:3.10" "grafana-latest.linux-x64-musl.tar.gz" "${_docker_repo}:${_grafana_version}"
if [ $BUILD_FAST = "0" ]; then
docker_build "arm32v7/alpine:3.10" "grafana-latest.linux-armv7-musl.tar.gz" "${_docker_repo}-arm32v7-linux:${_grafana_version}"
docker_build "arm64v8/alpine:3.10" "grafana-latest.linux-arm64-musl.tar.gz" "${_docker_repo}-arm64v8-linux:${_grafana_version}"
fi
docker_build "x64"
if [ $BUILD_FAST = "0" ]; then
docker_build "armv7"
docker_build "arm64"
fi
# Tag as 'latest' for official release; otherwise tag as grafana/grafana:master
if echo "$_grafana_tag" | grep -q "^v"; then
docker_tag_all "${_docker_repo}" "latest"
# Tag as 'latest' for official release; otherwise tag as grafana/grafana:master
if echo "$_grafana_tag" | grep -q "^v"; then
docker_tag_all "latest"
# Create the expected tag for running the end to end tests successfully
docker tag "${_docker_repo}:${_grafana_version}" "grafana/grafana-dev:${_grafana_tag}"
else
docker_tag_all "${_docker_repo}" "master"
docker tag "${_docker_repo}:${_grafana_version}" "grafana/grafana-dev:${_grafana_version}"
fi
docker tag "${_docker_repo}:${_grafana_version}${TAG_SUFFIX}" "grafana/grafana-dev:${_grafana_tag}${TAG_SUFFIX}"
else
docker_build "ubuntu:18.10" "grafana-latest.linux-x64.tar.gz" "${_docker_repo}:${_grafana_version}-ubuntu" Dockerfile.ubuntu
# Tag as 'latest-ubuntu' for official release; otherwise tag as grafana/grafana:master-ubuntu
if echo "$_grafana_tag" | grep -q "^v"; then
docker tag "${_docker_repo}:${_grafana_version}-ubuntu" "${_docker_repo}:latest-ubuntu"
# Create the expected tag for running the end to end tests successfully
docker tag "${_docker_repo}:${_grafana_version}-ubuntu" "grafana/grafana-dev:${_grafana_tag}-ubuntu"
else
docker tag "${_docker_repo}:${_grafana_version}-ubuntu" "${_docker_repo}:master-ubuntu"
docker tag "${_docker_repo}:${_grafana_version}-ubuntu" "grafana/grafana-dev:${_grafana_version}-ubuntu"
fi
docker_tag_all "master"
docker tag "${_docker_repo}:${_grafana_version}${TAG_SUFFIX}" "grafana/grafana-dev:${_grafana_version}${TAG_SUFFIX}"
fi
......@@ -2,11 +2,13 @@
set -e
UBUNTU_BASE=0
TAG_SUFFIX=""
while [ "$1" != "" ]; do
case "$1" in
"--ubuntu")
UBUNTU_BASE=1
TAG_SUFFIX="-ubuntu"
echo "Ubuntu base image enabled"
shift
;;
......@@ -29,60 +31,39 @@ fi
export DOCKER_CLI_EXPERIMENTAL=enabled
if [ $UBUNTU_BASE = "0" ]; then
echo "pushing ${_docker_repo}:${_grafana_version}"
else
echo "pushing ${_docker_repo}:${_grafana_version}-ubuntu"
fi
echo "pushing ${_docker_repo}:${_grafana_version}${TAG_SUFFIX}"
docker_push_all () {
repo=$1
tag=$2
if [ $UBUNTU_BASE = "0" ]; then
# Push each image individually
docker push "${repo}:${tag}"
docker push "${repo}-arm32v7-linux:${tag}"
docker push "${repo}-arm64v8-linux:${tag}"
docker push "${repo}:${tag}${TAG_SUFFIX}"
docker push "${repo}-arm32v7-linux:${tag}${TAG_SUFFIX}"
docker push "${repo}-arm64v8-linux:${tag}${TAG_SUFFIX}"
# Create and push a multi-arch manifest
docker manifest create "${repo}:${tag}" \
"${repo}:${tag}" \
"${repo}-arm32v7-linux:${tag}" \
"${repo}-arm64v8-linux:${tag}"
docker manifest create "${repo}:${tag}${TAG_SUFFIX}" \
"${repo}:${tag}${TAG_SUFFIX}" \
"${repo}-arm32v7-linux:${tag}${TAG_SUFFIX}" \
"${repo}-arm64v8-linux:${tag}${TAG_SUFFIX}"
docker manifest push "${repo}:${tag}"
else
docker push "${repo}:${tag}-ubuntu"
fi
docker manifest push "${repo}:${tag}${TAG_SUFFIX}"
}
if echo "$_grafana_tag" | grep -q "^v" && echo "$_grafana_tag" | grep -vq "beta"; then
echo "pushing ${_docker_repo}:latest"
echo "pushing ${_docker_repo}:latest${TAG_SUFFIX}"
docker_push_all "${_docker_repo}" "latest"
docker_push_all "${_docker_repo}" "${_grafana_version}"
# Push to the grafana-dev repository with the expected tag
# for running the end to end tests successfully
if [ ${UBUNTU_BASE} = "0" ]; then
docker push "grafana/grafana-dev:${_grafana_tag}"
else
docker push "grafana/grafana-dev:${_grafana_tag}-ubuntu"
fi
docker push "grafana/grafana-dev:${_grafana_tag}${TAG_SUFFIX}"
elif echo "$_grafana_tag" | grep -q "^v" && echo "$_grafana_tag" | grep -q "beta"; then
docker_push_all "${_docker_repo}" "${_grafana_version}"
# Push to the grafana-dev repository with the expected tag
# for running the end to end tests successfully
if [ ${UBUNTU_BASE} = "0" ]; then
docker push "grafana/grafana-dev:${_grafana_tag}"
else
docker push "grafana/grafana-dev:${_grafana_tag}-ubuntu"
fi
docker push "grafana/grafana-dev:${_grafana_tag}${TAG_SUFFIX}"
elif echo "$_grafana_tag" | grep -q "master"; then
docker_push_all "${_docker_repo}" "master"
if [ ${UBUNTU_BASE} = "0" ]; then
docker push "grafana/grafana-dev:${_grafana_version}"
else
docker push "grafana/grafana-dev:${_grafana_version}-ubuntu"
fi
docker push "grafana/grafana-dev:${_grafana_version}${TAG_SUFFIX}"
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment