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 ...@@ -3,6 +3,7 @@ set -e
BUILD_FAST=0 BUILD_FAST=0
UBUNTU_BASE=0 UBUNTU_BASE=0
TAG_SUFFIX=""
while [ "$1" != "" ]; do while [ "$1" != "" ]; do
case "$1" in case "$1" in
...@@ -13,6 +14,7 @@ while [ "$1" != "" ]; do ...@@ -13,6 +14,7 @@ while [ "$1" != "" ]; do
;; ;;
"--ubuntu") "--ubuntu")
UBUNTU_BASE=1 UBUNTU_BASE=1
TAG_SUFFIX="-ubuntu"
echo "Ubuntu base image enabled" echo "Ubuntu base image enabled"
shift shift
;; ;;
...@@ -33,20 +35,40 @@ else ...@@ -33,20 +35,40 @@ else
_grafana_version=$_grafana_tag _grafana_version=$_grafana_tag
fi fi
if [ $UBUNTU_BASE = "0" ]; then echo "Building ${_docker_repo}:${_grafana_version}${TAG_SUFFIX}"
echo "Building ${_docker_repo}:${_grafana_version}"
else
echo "Building ${_docker_repo}:${_grafana_version}-ubuntu"
fi
export DOCKER_CLI_EXPERIMENTAL=enabled export DOCKER_CLI_EXPERIMENTAL=enabled
# Build grafana image for a specific arch # Build grafana image for a specific arch
docker_build () { docker_build () {
base_image=$1 arch=$1
grafana_tgz=$2
tag=$3 case "$arch" in
dockerfile=${4:-Dockerfile} "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 \ docker build \
--build-arg BASE_IMAGE=${base_image} \ --build-arg BASE_IMAGE=${base_image} \
...@@ -58,48 +80,34 @@ docker_build () { ...@@ -58,48 +80,34 @@ docker_build () {
} }
docker_tag_linux_amd64 () { docker_tag_linux_amd64 () {
repo=$1 tag=$1
tag=$2 docker tag "${_docker_repo}:${_grafana_version}${TAG_SUFFIX}" "${_docker_repo}:${tag}${TAG_SUFFIX}"
docker tag "${_docker_repo}:${_grafana_version}" "${repo}:${tag}"
} }
# Tag docker images of all architectures # Tag docker images of all architectures
docker_tag_all () { docker_tag_all () {
repo=$1 tag=$1
tag=$2 docker_tag_linux_amd64 $1
docker_tag_linux_amd64 $1 $2
if [ $BUILD_FAST = "0" ]; then if [ $BUILD_FAST = "0" ]; then
docker tag "${_docker_repo}-arm32v7-linux:${_grafana_version}" "${repo}-arm32v7-linux:${tag}" docker tag "${_docker_repo}-arm32v7-linux:${_grafana_version}${TAG_SUFFIX}"
docker tag "${_docker_repo}-arm64v8-linux:${_grafana_version}" "${repo}-arm64v8-linux:${tag}" "${_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 fi
} }
if [ $UBUNTU_BASE = "0" ]; then docker_build "x64"
docker_build "alpine:3.10" "grafana-latest.linux-x64-musl.tar.gz" "${_docker_repo}:${_grafana_version}" if [ $BUILD_FAST = "0" ]; then
if [ $BUILD_FAST = "0" ]; then docker_build "armv7"
docker_build "arm32v7/alpine:3.10" "grafana-latest.linux-armv7-musl.tar.gz" "${_docker_repo}-arm32v7-linux:${_grafana_version}" docker_build "arm64"
docker_build "arm64v8/alpine:3.10" "grafana-latest.linux-arm64-musl.tar.gz" "${_docker_repo}-arm64v8-linux:${_grafana_version}" fi
fi
# Tag as 'latest' for official release; otherwise tag as grafana/grafana:master # Tag as 'latest' for official release; otherwise tag as grafana/grafana:master
if echo "$_grafana_tag" | grep -q "^v"; then if echo "$_grafana_tag" | grep -q "^v"; then
docker_tag_all "${_docker_repo}" "latest" docker_tag_all "latest"
# Create the expected tag for running the end to end tests successfully # Create the expected tag for running the end to end tests successfully
docker tag "${_docker_repo}:${_grafana_version}" "grafana/grafana-dev:${_grafana_tag}" docker tag "${_docker_repo}:${_grafana_version}${TAG_SUFFIX}" "grafana/grafana-dev:${_grafana_tag}${TAG_SUFFIX}"
else
docker_tag_all "${_docker_repo}" "master"
docker tag "${_docker_repo}:${_grafana_version}" "grafana/grafana-dev:${_grafana_version}"
fi
else else
docker_build "ubuntu:18.10" "grafana-latest.linux-x64.tar.gz" "${_docker_repo}:${_grafana_version}-ubuntu" Dockerfile.ubuntu docker_tag_all "master"
docker tag "${_docker_repo}:${_grafana_version}${TAG_SUFFIX}" "grafana/grafana-dev:${_grafana_version}${TAG_SUFFIX}"
# 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
fi fi
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
set -e set -e
UBUNTU_BASE=0 UBUNTU_BASE=0
TAG_SUFFIX=""
while [ "$1" != "" ]; do while [ "$1" != "" ]; do
case "$1" in case "$1" in
"--ubuntu") "--ubuntu")
UBUNTU_BASE=1 UBUNTU_BASE=1
TAG_SUFFIX="-ubuntu"
echo "Ubuntu base image enabled" echo "Ubuntu base image enabled"
shift shift
;; ;;
...@@ -29,60 +31,39 @@ fi ...@@ -29,60 +31,39 @@ fi
export DOCKER_CLI_EXPERIMENTAL=enabled export DOCKER_CLI_EXPERIMENTAL=enabled
if [ $UBUNTU_BASE = "0" ]; then echo "pushing ${_docker_repo}:${_grafana_version}${TAG_SUFFIX}"
echo "pushing ${_docker_repo}:${_grafana_version}"
else
echo "pushing ${_docker_repo}:${_grafana_version}-ubuntu"
fi
docker_push_all () { docker_push_all () {
repo=$1 repo=$1
tag=$2 tag=$2
if [ $UBUNTU_BASE = "0" ]; then
# Push each image individually # Push each image individually
docker push "${repo}:${tag}" docker push "${repo}:${tag}${TAG_SUFFIX}"
docker push "${repo}-arm32v7-linux:${tag}" docker push "${repo}-arm32v7-linux:${tag}${TAG_SUFFIX}"
docker push "${repo}-arm64v8-linux:${tag}" docker push "${repo}-arm64v8-linux:${tag}${TAG_SUFFIX}"
# Create and push a multi-arch manifest # Create and push a multi-arch manifest
docker manifest create "${repo}:${tag}" \ docker manifest create "${repo}:${tag}${TAG_SUFFIX}" \
"${repo}:${tag}" \ "${repo}:${tag}${TAG_SUFFIX}" \
"${repo}-arm32v7-linux:${tag}" \ "${repo}-arm32v7-linux:${tag}${TAG_SUFFIX}" \
"${repo}-arm64v8-linux:${tag}" "${repo}-arm64v8-linux:${tag}${TAG_SUFFIX}"
docker manifest push "${repo}:${tag}" docker manifest push "${repo}:${tag}${TAG_SUFFIX}"
else
docker push "${repo}:${tag}-ubuntu"
fi
} }
if echo "$_grafana_tag" | grep -q "^v" && echo "$_grafana_tag" | grep -vq "beta"; then 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}" "latest"
docker_push_all "${_docker_repo}" "${_grafana_version}" docker_push_all "${_docker_repo}" "${_grafana_version}"
# Push to the grafana-dev repository with the expected tag # Push to the grafana-dev repository with the expected tag
# for running the end to end tests successfully # for running the end to end tests successfully
if [ ${UBUNTU_BASE} = "0" ]; then docker push "grafana/grafana-dev:${_grafana_tag}${TAG_SUFFIX}"
docker push "grafana/grafana-dev:${_grafana_tag}"
else
docker push "grafana/grafana-dev:${_grafana_tag}-ubuntu"
fi
elif echo "$_grafana_tag" | grep -q "^v" && echo "$_grafana_tag" | grep -q "beta"; then elif echo "$_grafana_tag" | grep -q "^v" && echo "$_grafana_tag" | grep -q "beta"; then
docker_push_all "${_docker_repo}" "${_grafana_version}" docker_push_all "${_docker_repo}" "${_grafana_version}"
# Push to the grafana-dev repository with the expected tag # Push to the grafana-dev repository with the expected tag
# for running the end to end tests successfully # for running the end to end tests successfully
if [ ${UBUNTU_BASE} = "0" ]; then docker push "grafana/grafana-dev:${_grafana_tag}${TAG_SUFFIX}"
docker push "grafana/grafana-dev:${_grafana_tag}"
else
docker push "grafana/grafana-dev:${_grafana_tag}-ubuntu"
fi
elif echo "$_grafana_tag" | grep -q "master"; then elif echo "$_grafana_tag" | grep -q "master"; then
docker_push_all "${_docker_repo}" "master" docker_push_all "${_docker_repo}" "master"
if [ ${UBUNTU_BASE} = "0" ]; then docker push "grafana/grafana-dev:${_grafana_version}${TAG_SUFFIX}"
docker push "grafana/grafana-dev:${_grafana_version}"
else
docker push "grafana/grafana-dev:${_grafana_version}-ubuntu"
fi
fi 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