Skip to content

Commit 3c7c067

Browse files
committed
all: imp ci scripts
1 parent 69f1a72 commit 3c7c067

File tree

2 files changed

+55
-36
lines changed

2 files changed

+55
-36
lines changed

.github/workflows/docker.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
'key': "${{ runner.os }}-go-${{ hashFiles('go.sum') }}"
3131
'restore-keys': '${{ runner.os }}-go-'
3232
- 'name': 'Set up QEMU'
33-
'uses': 'docker/setup-qemu-action@v1'
33+
'uses': 'docker/setup-qemu-action@v3'
3434
- 'name': 'Set up Docker Buildx'
35-
'uses': 'docker/setup-buildx-action@v1'
35+
'uses': 'docker/setup-buildx-action@v3'
36+
'with':
37+
'install': true'
3638
- 'name': 'Publish to Docker Hub'
3739
'env':
3840
'DOCKER_USER': ${{ secrets.DOCKER_USER }}
@@ -51,7 +53,7 @@
5153
make \
5254
VERSION="${RELEASE_VERSION}" \
5355
DOCKER_IMAGE_NAME="adguard/dnsproxy" \
54-
DOCKER_OUTPUT="type=image,name=adguard/dnsproxy,push=true" \
56+
DOCKER_PUSH="1" \
5557
VERBOSE="1" \
5658
docker
5759

scripts/make/build-docker.sh

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ verbose="${VERBOSE:-0}"
44

55
if [ "$verbose" -gt '0' ]; then
66
set -x
7-
debug_flags='--debug=1'
87
else
98
set +x
10-
debug_flags='--debug=0'
119
fi
12-
readonly debug_flags
1310

1411
set -e -f -u
1512

@@ -40,15 +37,9 @@ readonly build_date
4037
docker_image_name="${DOCKER_IMAGE_NAME:-dnsproxy-dev}"
4138
readonly docker_image_name
4239

43-
# Set DOCKER_OUTPUT to 'type=image,name=adguard/dnsproxy,push=true' if you
44-
# want (and are allowed) to push to DockerHub.
45-
#
46-
# If you want to inspect the resulting image using commands like "docker image
47-
# ls", change type to docker and also set docker_platforms to a single platform.
48-
#
49-
# See https://github.com/docker/buildx/issues/166.
50-
docker_output="${DOCKER_OUTPUT:-type=image,name=${docker_image_name},push=false}"
51-
readonly docker_output
40+
# Set DOCKER_PUSH to '1' if you want (and are allowed) to push to DockerHub.
41+
docker_push="${DOCKER_PUSH:-0}"
42+
readonly docker_push
5243

5344
docker_version_tag="--tag=${docker_image_name}:${version}"
5445
docker_channel_tag="--tag=${docker_image_name}:latest"
@@ -84,24 +75,50 @@ cp "${dist_dir}/linux-ppc64le/dnsproxy" \
8475
# Prepare the default configuration for the Docker image.
8576
cp ./config.yaml.dist "${dist_docker}/config.yaml"
8677

87-
# Don't use quotes with $docker_version_tag and $docker_channel_tag, because we
88-
# want word splitting and or an empty space if tags are empty.
89-
#
90-
# TODO(a.garipov): Once flag --tag of docker buildx build supports commas, use
91-
# them instead.
92-
#
93-
# shellcheck disable=SC2086
94-
$sudo_cmd docker \
95-
"$debug_flags" \
96-
buildx build \
97-
--build-arg BUILD_DATE="$build_date" \
98-
--build-arg DIST_DIR="$dist_dir" \
99-
--build-arg VCS_REF="$commit" \
100-
--build-arg VERSION="$version" \
101-
--output "$docker_output" \
102-
--platform "$docker_platforms" \
103-
$docker_version_tag \
104-
$docker_channel_tag \
105-
-f ./docker/build.Dockerfile \
106-
. \
107-
;
78+
# docker_build_opt_tag is a function that wraps the call of docker build command
79+
# with optionally --tag flags.
80+
docker_build_opt_tag() {
81+
if [ "$sudo_cmd" != '' ]; then
82+
set -- "$sudo_cmd"
83+
fi
84+
85+
# Set the initial parameters.
86+
set -- \
87+
"$@" \
88+
docker \
89+
buildx \
90+
build \
91+
--build-arg BUILD_DATE="$build_date" \
92+
--build-arg DIST_DIR="$dist_dir" \
93+
--build-arg VCS_REF="$commit" \
94+
--build-arg VERSION="$version" \
95+
--platform "$docker_platforms" \
96+
--progress 'plain' \
97+
;
98+
99+
# Append the channel tag, if any.
100+
if [ "$docker_channel_tag" != '' ]; then
101+
set -- "$@" "$docker_channel_tag"
102+
fi
103+
104+
# Append the version tag.
105+
set -- "$@" "$docker_version_tag"
106+
107+
# Push to DockerHub, if requested.
108+
if [ "$docker_push" -eq 1 ]; then
109+
set -- "$@" '--push'
110+
fi
111+
112+
# Append the rest.
113+
set -- \
114+
"$@" \
115+
-f \
116+
./docker/build.Dockerfile \
117+
. \
118+
;
119+
120+
# Call the command with the assembled parameters.
121+
"$@"
122+
}
123+
124+
docker_build_opt_tag

0 commit comments

Comments
 (0)