2020-12-30 15:26:25 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
verbose="${VERBOSE:-0}"
|
|
|
|
|
|
|
|
if [ "$verbose" -gt '0' ]
|
|
|
|
then
|
|
|
|
set -x
|
|
|
|
debug_flags='-D'
|
|
|
|
else
|
|
|
|
set +x
|
|
|
|
debug_flags=''
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e -f -u
|
|
|
|
|
|
|
|
# Require these to be set. The channel value is validated later.
|
2021-05-19 17:31:20 +00:00
|
|
|
channel="$CHANNEL"
|
|
|
|
commit="$COMMIT"
|
|
|
|
dist_dir="$DIST_DIR"
|
|
|
|
readonly channel commit dist_dir
|
2021-02-11 09:55:23 +00:00
|
|
|
|
2021-04-09 12:07:18 +00:00
|
|
|
if [ "${VERSION:-}" = 'v0.0.0' ] || [ "${VERSION:-}" = '' ]
|
2021-02-11 09:55:23 +00:00
|
|
|
then
|
2021-05-19 17:31:20 +00:00
|
|
|
version="$( sh ./scripts/make/version.sh )"
|
2021-02-11 09:55:23 +00:00
|
|
|
else
|
2021-05-19 17:31:20 +00:00
|
|
|
version="$VERSION"
|
2021-02-11 09:55:23 +00:00
|
|
|
fi
|
2021-05-19 17:31:20 +00:00
|
|
|
readonly version
|
2021-02-11 09:55:23 +00:00
|
|
|
|
|
|
|
echo $version
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
# Allow users to use sudo.
|
2021-05-19 17:31:20 +00:00
|
|
|
sudo_cmd="${SUDO:-}"
|
|
|
|
readonly sudo_cmd
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-05-19 17:31:20 +00:00
|
|
|
docker_platforms="\
|
2020-12-30 15:26:25 +00:00
|
|
|
linux/386,\
|
|
|
|
linux/amd64,\
|
|
|
|
linux/arm/v6,\
|
|
|
|
linux/arm/v7,\
|
|
|
|
linux/arm64,\
|
|
|
|
linux/ppc64le"
|
2021-05-19 17:31:20 +00:00
|
|
|
readonly docker_platforms
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-05-19 17:31:20 +00:00
|
|
|
build_date="$( date -u +'%Y-%m-%dT%H:%M:%SZ' )"
|
|
|
|
readonly build_date
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-05-19 17:31:20 +00:00
|
|
|
# Set DOCKER_IMAGE_NAME to 'adguard/adguard-home' if you want (and are allowed)
|
|
|
|
# to push to DockerHub.
|
|
|
|
docker_image_name="${DOCKER_IMAGE_NAME:-adguardhome-dev}"
|
|
|
|
readonly docker_image_name
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-05-19 17:31:20 +00:00
|
|
|
# Set DOCKER_OUTPUT to 'type=image,name=adguard/adguard-home,push=true' if you
|
|
|
|
# want (and are allowed) to push to DockerHub.
|
|
|
|
docker_output="${DOCKER_OUTPUT:-type=image,name=${docker_image_name},push=false}"
|
|
|
|
readonly docker_output
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
case "$channel"
|
|
|
|
in
|
|
|
|
('release')
|
2021-05-19 17:31:20 +00:00
|
|
|
docker_image_full_name="${docker_image_name}:${version}"
|
|
|
|
docker_tags="--tag ${docker_image_name}:latest"
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
|
|
|
('beta')
|
2021-05-19 17:31:20 +00:00
|
|
|
docker_image_full_name="${docker_image_name}:${version}"
|
|
|
|
docker_tags="--tag ${docker_image_name}:beta"
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
|
|
|
('edge')
|
|
|
|
# Don't set the version tag when pushing to the edge channel.
|
2021-05-19 17:31:20 +00:00
|
|
|
docker_image_full_name="${docker_image_name}:edge"
|
|
|
|
docker_tags=''
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
|
|
|
('development')
|
2021-05-19 17:31:20 +00:00
|
|
|
docker_image_full_name="${docker_image_name}"
|
|
|
|
docker_tags=''
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
|
|
|
(*)
|
|
|
|
echo "invalid channel '$channel', supported values are\
|
|
|
|
'development', 'edge', 'beta', and 'release'" 1>&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2021-05-19 17:31:20 +00:00
|
|
|
readonly docker_image_full_name docker_tags
|
|
|
|
|
|
|
|
# Copy the binaries into a new directory under new names, so that it's eaiser to
|
|
|
|
# COPY them later. DO NOT remove the trailing underscores. See file
|
|
|
|
# scripts/make/Dockerfile.
|
|
|
|
dist_docker="${dist_dir}/docker"
|
|
|
|
readonly dist_docker
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
mkdir -p "$dist_docker"
|
|
|
|
cp "${dist_dir}/AdGuardHome_linux_386/AdGuardHome/AdGuardHome"\
|
|
|
|
"${dist_docker}/AdGuardHome_linux_386_"
|
|
|
|
cp "${dist_dir}/AdGuardHome_linux_amd64/AdGuardHome/AdGuardHome"\
|
|
|
|
"${dist_docker}/AdGuardHome_linux_amd64_"
|
|
|
|
cp "${dist_dir}/AdGuardHome_linux_arm64/AdGuardHome/AdGuardHome"\
|
|
|
|
"${dist_docker}/AdGuardHome_linux_arm64_"
|
|
|
|
cp "${dist_dir}/AdGuardHome_linux_arm_6/AdGuardHome/AdGuardHome"\
|
|
|
|
"${dist_docker}/AdGuardHome_linux_arm_v6"
|
|
|
|
cp "${dist_dir}/AdGuardHome_linux_arm_7/AdGuardHome/AdGuardHome"\
|
|
|
|
"${dist_docker}/AdGuardHome_linux_arm_v7"
|
|
|
|
cp "${dist_dir}/AdGuardHome_linux_ppc64le/AdGuardHome/AdGuardHome"\
|
|
|
|
"${dist_docker}/AdGuardHome_linux_ppc64le_"
|
|
|
|
|
2021-05-19 17:31:20 +00:00
|
|
|
# Don't use quotes with $docker_tags and $debug_flags because we want word
|
|
|
|
# splitting and or an empty space if tags are empty.
|
2020-12-30 15:26:25 +00:00
|
|
|
$sudo_cmd docker\
|
|
|
|
$debug_flags\
|
|
|
|
buildx build\
|
|
|
|
--build-arg BUILD_DATE="$build_date"\
|
|
|
|
--build-arg DIST_DIR="$dist_dir"\
|
|
|
|
--build-arg VCS_REF="$commit"\
|
|
|
|
--build-arg VERSION="$version"\
|
|
|
|
--output "$docker_output"\
|
|
|
|
--platform "$docker_platforms"\
|
|
|
|
$docker_tags\
|
|
|
|
-t "$docker_image_full_name"\
|
|
|
|
-f ./scripts/make/Dockerfile\
|
|
|
|
.
|