2018-10-16 05:13:58 +02:00
|
|
|
#!/bin/bash -e
|
2018-08-14 06:37:15 +02:00
|
|
|
# Script for manually pushing the docker arm images for diginc only
|
2018-02-23 06:11:53 +01:00
|
|
|
# (no one else has docker repo permissions)
|
|
|
|
if [ ! -f ~/.docker/config.json ] ; then
|
|
|
|
echo "Error: You should setup your docker push authorization first"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-07-12 18:34:47 +02:00
|
|
|
parse_git_branch() {
|
|
|
|
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
|
|
|
|
}
|
|
|
|
|
2018-08-12 22:30:40 +02:00
|
|
|
annotate() {
|
|
|
|
local base=$1
|
|
|
|
local image=$2
|
|
|
|
local arch=${image##*_}
|
|
|
|
local docker_arch=${arch_map[$arch]}
|
|
|
|
|
|
|
|
if [ -z $docker_arch ]; then
|
|
|
|
echo "Unknown arch in docker tag: ${arch}"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
$dry docker manifest annotate ${base} ${image} --os linux --arch ${docker_arch}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-08-04 20:31:58 +02:00
|
|
|
namespace='pihole'
|
|
|
|
localimg='pihole'
|
|
|
|
remoteimg="$namespace/$localimg"
|
2018-07-12 18:34:47 +02:00
|
|
|
branch="$(parse_git_branch)"
|
|
|
|
version="${version:-unset}"
|
|
|
|
dry="${dry}"
|
2018-08-05 02:33:45 +02:00
|
|
|
latest="${latest:-false}" # true as shell env var to deploy latest
|
2018-07-12 18:34:47 +02:00
|
|
|
|
2018-08-12 22:30:40 +02:00
|
|
|
# arch aliases
|
2018-10-16 05:13:58 +02:00
|
|
|
# ARMv6/armel doesn't have a FTL binary for v4.0 pi-hole
|
2018-08-12 22:30:40 +02:00
|
|
|
declare -A arch_map=( ["amd64"]="amd64" ["armhf"]="arm" ["aarch64"]="arm64")
|
|
|
|
|
2018-10-16 05:13:58 +02:00
|
|
|
# Set anything to dry prior to running this in order to print what would run instead of actually run it.
|
2018-08-04 21:24:44 +02:00
|
|
|
if [[ -n "$dry" ]]; then dry='echo '; fi
|
2018-07-12 18:34:47 +02:00
|
|
|
|
2018-08-04 20:31:58 +02:00
|
|
|
if [[ "$version" == 'unset' ]]; then
|
|
|
|
if [[ "$branch" == "master" ]]; then
|
|
|
|
echo "Version number var is unset and master branch needs a version...pass in \$version variable!"
|
|
|
|
exit 1
|
2018-08-04 21:24:44 +02:00
|
|
|
elif [[ "$branch" = "release/"* ]]; then
|
2018-08-05 02:33:45 +02:00
|
|
|
version="$(echo $branch | grep -Po 'v[\d\.-]*')"
|
2018-08-04 21:24:44 +02:00
|
|
|
echo "Version number is being taken from this release branch $version"
|
|
|
|
else
|
|
|
|
version="$branch"
|
2018-08-14 06:37:15 +02:00
|
|
|
# Use a different image for segregating dev tags maybe? Not right now, just a thought I had
|
|
|
|
#remoteimg="${namespace}/${localimg}-dev"
|
2018-08-04 21:24:44 +02:00
|
|
|
echo "Using the branch ($branch) for deployed image version since not passed in"
|
2018-08-04 20:31:58 +02:00
|
|
|
fi
|
2018-07-12 18:34:47 +02:00
|
|
|
fi
|
|
|
|
|
2018-07-12 18:36:36 +02:00
|
|
|
echo "# DEPLOYING:"
|
2018-07-12 18:34:47 +02:00
|
|
|
echo "version: $version"
|
|
|
|
echo "branch: $branch"
|
|
|
|
[[ -n "$dry" ]] && echo "DRY RUN: $dry"
|
2018-10-16 05:13:58 +02:00
|
|
|
echo "Example tagging: docker tag ${localimg}:armhf ${remoteimg}:${version}_amd64"
|
2018-07-12 18:34:47 +02:00
|
|
|
|
2018-12-14 02:06:02 +01:00
|
|
|
if [[ -z "$dry" ]] ; then
|
|
|
|
echo "Deleting all manifest data to work around cached old copies preventing updates"
|
|
|
|
rm -rf ~/.docker/manifests/*
|
|
|
|
fi
|
|
|
|
|
2018-10-30 06:20:45 +01:00
|
|
|
$dry tox
|
2018-07-12 18:34:47 +02:00
|
|
|
|
2018-08-12 22:30:40 +02:00
|
|
|
images=()
|
|
|
|
for tag in ${!arch_map[@]}; do
|
2018-08-04 21:24:44 +02:00
|
|
|
# Verison specific tags for ongoing history
|
2019-01-01 20:51:33 +01:00
|
|
|
$dry docker tag $localimg:v4.1.1_$tag $remoteimg:${version}_${tag}
|
2018-08-12 22:30:40 +02:00
|
|
|
$dry docker push pihole/pihole:${version}_${tag}
|
|
|
|
images+=(pihole/pihole:${version}_${tag})
|
2018-08-04 21:24:44 +02:00
|
|
|
done
|
2018-08-12 22:30:40 +02:00
|
|
|
|
|
|
|
$dry docker manifest create --amend pihole/pihole:${version} ${images[*]}
|
|
|
|
|
|
|
|
for image in "${images[@]}"; do
|
|
|
|
annotate pihole/pihole:${version} ${image}
|
|
|
|
done
|
|
|
|
|
|
|
|
$dry docker manifest push pihole/pihole:${version}
|
|
|
|
|
2018-08-14 06:37:15 +02:00
|
|
|
# Floating latest tag alias
|
|
|
|
if [[ "$latest" == 'true' && "$branch" == "master" ]] ; then
|
|
|
|
latestimg="$remoteimg:latest"
|
|
|
|
$dry docker manifest create --amend "$latestimg" ${images[*]}
|
2018-08-12 22:30:40 +02:00
|
|
|
for image in "${images[@]}"; do
|
2018-08-14 06:37:15 +02:00
|
|
|
annotate "$latestimg" "${image}"
|
2018-08-12 22:30:40 +02:00
|
|
|
done
|
2018-08-14 06:37:15 +02:00
|
|
|
$dry docker manifest push "$latestimg"
|
2018-08-12 22:30:40 +02:00
|
|
|
fi
|