Make image build logs verbose if necessary

The `-q` flag is not implemented by `docker buildx`, which results in an
output:

```
WARN[0000] quiet currently not implemented.
```

In the same way, the build output is not logged to `stdout` (but
`stderr`). This means we now dump the whole build process to a file and
if the `docker buildx` command fails, then we output those logs by
printing the contents of that file. This will also reduce the overall
verbosity and aligns to the original `docker build` behavior.

Signed-off-by: Sascha Grunert <mail@saschagrunert.de>
This commit is contained in:
Sascha Grunert 2021-01-29 11:14:15 +01:00
parent 645c40fcf6
commit 54db83eef8
No known key found for this signature in database
GPG Key ID: BEDA150F1B0AFEEC

View File

@ -383,12 +383,16 @@ EOF
echo "COPY nsswitch.conf /etc/" >> "${docker_file_path}"
fi
DOCKER_CLI_EXPERIMENTAL=enabled "${DOCKER[@]}" buildx build \
local build_log="${docker_build_path}/build.log"
if ! DOCKER_CLI_EXPERIMENTAL=enabled "${DOCKER[@]}" buildx build \
--platform linux/"${arch}" \
--load ${docker_build_opts:+"${docker_build_opts}"} \
-q \
-t "${docker_image_tag}" \
"${docker_build_path}" >/dev/null
"${docker_build_path}" >"${build_log}" 2>&1; then
cat "${build_log}"
exit 1
fi
rm "${build_log}"
# If we are building an official/alpha/beta release we want to keep
# docker images and tag them appropriately.