2019-01-29 12:11:11 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eE
|
|
|
|
set -o pipefail
|
|
|
|
set -x
|
|
|
|
|
2020-04-21 13:05:13 +01:00
|
|
|
DOCKERFILE="packaging/docker/Dockerfile.hub"
|
2019-02-11 12:10:36 +00:00
|
|
|
IMAGE_NAME="adguard/adguardhome"
|
|
|
|
|
|
|
|
if [[ "${TRAVIS_BRANCH}" == "master" ]]
|
2019-01-29 12:11:11 +00:00
|
|
|
then
|
2019-02-11 12:10:36 +00:00
|
|
|
VERSION="edge"
|
2019-01-29 12:11:11 +00:00
|
|
|
else
|
|
|
|
VERSION=`git describe --abbrev=4 --dirty --always --tags`
|
|
|
|
fi
|
|
|
|
|
|
|
|
build_image() {
|
|
|
|
from="$(awk '$1 == toupper("FROM") { print $2 }' ${DOCKERFILE})"
|
|
|
|
|
|
|
|
# See https://hub.docker.com/r/multiarch/alpine/tags
|
|
|
|
case "${GOARCH}" in
|
|
|
|
arm64)
|
|
|
|
alpineArch='arm64-edge'
|
|
|
|
imageArch='arm64'
|
|
|
|
;;
|
|
|
|
arm)
|
|
|
|
alpineArch='armhf-edge'
|
|
|
|
imageArch='armhf'
|
|
|
|
;;
|
|
|
|
386)
|
|
|
|
alpineArch='i386-edge'
|
|
|
|
imageArch='i386'
|
|
|
|
;;
|
|
|
|
amd64)
|
|
|
|
alpineArch='amd64-edge'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
alpineArch='amd64-edge'
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2019-02-11 12:10:36 +00:00
|
|
|
if [[ "${GOOS}" == "linux" ]] && [[ "${GOARCH}" == "amd64" ]]
|
2019-01-29 12:11:11 +00:00
|
|
|
then
|
2019-02-11 12:10:36 +00:00
|
|
|
image="${IMAGE_NAME}:${VERSION}"
|
2019-01-29 12:11:11 +00:00
|
|
|
else
|
2019-02-11 12:10:36 +00:00
|
|
|
image="${IMAGE_NAME}:${imageArch}-${VERSION}"
|
2019-01-29 12:11:11 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
make cleanfast; CGO_DISABLED=1 make
|
|
|
|
|
|
|
|
docker pull "multiarch/alpine:${alpineArch}"
|
|
|
|
docker tag "multiarch/alpine:${alpineArch}" "$from"
|
|
|
|
docker build -t "${image}" -f ${DOCKERFILE} .
|
|
|
|
docker push ${image}
|
2019-02-11 12:10:36 +00:00
|
|
|
if [[ "${VERSION}" != "edge" ]]
|
|
|
|
then
|
|
|
|
latest=${image/$VERSION/latest}
|
|
|
|
docker tag "${image}" "${latest}"
|
|
|
|
docker push ${latest}
|
|
|
|
docker rmi ${latest}
|
|
|
|
fi
|
2019-01-29 12:11:11 +00:00
|
|
|
docker rmi "$from"
|
|
|
|
}
|
|
|
|
|
|
|
|
# prepare qemu
|
|
|
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
|
|
|
|
|
|
|
make clean
|
|
|
|
|
|
|
|
# Prepare releases
|
|
|
|
GOOS=linux GOARCH=amd64 build_image
|
|
|
|
GOOS=linux GOARCH=386 build_image
|
|
|
|
GOOS=linux GOARCH=arm GOARM=6 build_image
|
|
|
|
GOOS=linux GOARCH=arm64 GOARM=6 build_image
|