2020-12-30 15:26:25 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
verbose="${VERBOSE:-0}"
|
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "$verbose" -gt '0' ]; then
|
2020-12-30 15:26:25 +00:00
|
|
|
set -x
|
2023-06-21 15:14:10 +01:00
|
|
|
debug_flags='--debug=1'
|
2020-12-30 15:26:25 +00:00
|
|
|
else
|
|
|
|
set +x
|
2023-06-21 15:14:10 +01:00
|
|
|
debug_flags='--debug=0'
|
2020-12-30 15:26:25 +00:00
|
|
|
fi
|
2023-06-21 15:14:10 +01:00
|
|
|
readonly debug_flags
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
set -e -f -u
|
|
|
|
|
|
|
|
# Require these to be set. The channel value is validated later.
|
2021-06-10 18:09:00 +01:00
|
|
|
channel="${CHANNEL:?please set CHANNEL}"
|
2024-11-08 14:18:16 +00:00
|
|
|
commit="${REVISION:?please set REVISION}"
|
2021-06-10 18:09:00 +01:00
|
|
|
dist_dir="${DIST_DIR:?please set DIST_DIR}"
|
2021-05-19 18:31:20 +01:00
|
|
|
readonly channel commit dist_dir
|
2021-02-11 09:55:23 +00:00
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
if [ "${VERSION:-}" = 'v0.0.0' ] || [ "${VERSION:-}" = '' ]; then
|
|
|
|
version="$(sh ./scripts/make/version.sh)"
|
2021-02-11 09:55:23 +00:00
|
|
|
else
|
2021-05-19 18:31:20 +01:00
|
|
|
version="$VERSION"
|
2021-02-11 09:55:23 +00:00
|
|
|
fi
|
2021-05-19 18:31:20 +01:00
|
|
|
readonly version
|
2021-02-11 09:55:23 +00:00
|
|
|
|
2020-12-30 15:26:25 +00:00
|
|
|
# Allow users to use sudo.
|
2021-05-19 18:31:20 +01:00
|
|
|
sudo_cmd="${SUDO:-}"
|
|
|
|
readonly sudo_cmd
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-05-19 18:31:20 +01: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 18:31:20 +01:00
|
|
|
readonly docker_platforms
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
build_date="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
2021-05-19 18:31:20 +01:00
|
|
|
readonly build_date
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2021-05-19 18:31:20 +01: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 18:31:20 +01:00
|
|
|
# Set DOCKER_OUTPUT to 'type=image,name=adguard/adguard-home,push=true' if you
|
|
|
|
# want (and are allowed) to push to DockerHub.
|
2022-06-14 18:02:12 +01:00
|
|
|
#
|
|
|
|
# If you want to inspect the resulting image using commands like "docker image
|
|
|
|
# ls", change type to docker and also set docker_platforms to a single platform.
|
|
|
|
#
|
|
|
|
# See https://github.com/docker/buildx/issues/166.
|
2021-05-19 18:31:20 +01:00
|
|
|
docker_output="${DOCKER_OUTPUT:-type=image,name=${docker_image_name},push=false}"
|
|
|
|
readonly docker_output
|
2020-12-30 15:26:25 +00:00
|
|
|
|
2024-11-06 15:45:21 +00:00
|
|
|
case "$channel" in
|
|
|
|
'release')
|
2023-06-30 08:47:44 +01:00
|
|
|
docker_version_tag="--tag=${docker_image_name}:${version}"
|
|
|
|
docker_channel_tag="--tag=${docker_image_name}:latest"
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
2024-11-06 15:45:21 +00:00
|
|
|
'beta')
|
2023-06-30 08:47:44 +01:00
|
|
|
docker_version_tag="--tag=${docker_image_name}:${version}"
|
|
|
|
docker_channel_tag="--tag=${docker_image_name}:beta"
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
2024-11-06 15:45:21 +00:00
|
|
|
'edge')
|
2023-06-30 08:47:44 +01:00
|
|
|
# Set the version tag to an empty string when pushing to the edge channel.
|
|
|
|
docker_version_tag=''
|
|
|
|
docker_channel_tag="--tag=${docker_image_name}:edge"
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
2024-11-06 15:45:21 +00:00
|
|
|
'development')
|
2023-06-30 08:47:44 +01:00
|
|
|
# Set both tags to an empty string for development builds.
|
|
|
|
docker_version_tag=''
|
|
|
|
docker_channel_tag=''
|
2020-12-30 15:26:25 +00:00
|
|
|
;;
|
2024-11-06 15:45:21 +00:00
|
|
|
*)
|
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
|
2023-06-28 16:12:45 +01:00
|
|
|
readonly docker_version_tag docker_channel_tag
|
2021-05-19 18:31:20 +01:00
|
|
|
|
2023-01-11 11:48:46 +00:00
|
|
|
# Copy the binaries into a new directory under new names, so that it's easier to
|
2021-05-19 18:31:20 +01:00
|
|
|
# COPY them later. DO NOT remove the trailing underscores. See file
|
2023-03-26 21:12:24 +01:00
|
|
|
# docker/Dockerfile.
|
2021-05-19 18:31:20 +01:00
|
|
|
dist_docker="${dist_dir}/docker"
|
|
|
|
readonly dist_docker
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
mkdir -p "$dist_docker"
|
2024-11-06 15:45:21 +00:00
|
|
|
cp "${dist_dir}/AdGuardHome_linux_386/AdGuardHome/AdGuardHome" \
|
2020-12-30 15:26:25 +00:00
|
|
|
"${dist_docker}/AdGuardHome_linux_386_"
|
2024-11-06 15:45:21 +00:00
|
|
|
cp "${dist_dir}/AdGuardHome_linux_amd64/AdGuardHome/AdGuardHome" \
|
2020-12-30 15:26:25 +00:00
|
|
|
"${dist_docker}/AdGuardHome_linux_amd64_"
|
2024-11-06 15:45:21 +00:00
|
|
|
cp "${dist_dir}/AdGuardHome_linux_arm64/AdGuardHome/AdGuardHome" \
|
2020-12-30 15:26:25 +00:00
|
|
|
"${dist_docker}/AdGuardHome_linux_arm64_"
|
2024-11-06 15:45:21 +00:00
|
|
|
cp "${dist_dir}/AdGuardHome_linux_arm_6/AdGuardHome/AdGuardHome" \
|
2020-12-30 15:26:25 +00:00
|
|
|
"${dist_docker}/AdGuardHome_linux_arm_v6"
|
2024-11-06 15:45:21 +00:00
|
|
|
cp "${dist_dir}/AdGuardHome_linux_arm_7/AdGuardHome/AdGuardHome" \
|
2020-12-30 15:26:25 +00:00
|
|
|
"${dist_docker}/AdGuardHome_linux_arm_v7"
|
2024-11-06 15:45:21 +00:00
|
|
|
cp "${dist_dir}/AdGuardHome_linux_ppc64le/AdGuardHome/AdGuardHome" \
|
2020-12-30 15:26:25 +00:00
|
|
|
"${dist_docker}/AdGuardHome_linux_ppc64le_"
|
|
|
|
|
2023-06-30 08:47:44 +01:00
|
|
|
# Don't use quotes with $docker_version_tag and $docker_channel_tag, because we
|
|
|
|
# want word splitting and or an empty space if tags are empty.
|
|
|
|
#
|
|
|
|
# TODO(a.garipov): Once flag --tag of docker buildx build supports commas, use
|
|
|
|
# them instead.
|
2024-11-06 15:45:21 +00:00
|
|
|
#
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
$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_version_tag $docker_channel_tag -f ./docker/Dockerfile .
|