mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 19:16:23 +00:00
metrics:libs: Add HTTPS and HTTP vars to docker build.
Include HTTP and HTTPS env variables in the building docker images because they are required to download packages such as Phoronix. Added a restriction that verifies that docker building images is performed as root. Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
This commit is contained in:
parent
3355dd9e2b
commit
b37c5f8ba1
@ -90,10 +90,14 @@ function generate_build_dockerfile()
|
||||
local map_key="$3"
|
||||
local text_to_replace="$4"
|
||||
local regs=(${registries["${map_key}"]})
|
||||
|
||||
for r in ${regs[@]}; do
|
||||
sed 's|'${text_to_replace}'|'${r}'|g' \
|
||||
"${dockerfile}.in" > "${dockerfile}"
|
||||
if sudo "${DOCKER_EXE}" build --build-arg http_proxy="${http_proxy}" --build-arg https_proxy="${https_proxy}" --label "$image" --tag "${image}" -f "$dockerfile" "$dockerfile_dir"; then
|
||||
if sudo -E "${DOCKER_EXE}" build \
|
||||
--build-arg http_proxy="${http_proxy}" --build-arg https_proxy="${https_proxy}" \
|
||||
--build-arg HTTP_PROXY="${http_proxy}" --build-arg HTTPS_PROXY="${https_proxy}" \
|
||||
--label "$image" --tag "${image}" -f "$dockerfile" "$dockerfile_dir"; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
@ -111,7 +115,10 @@ function build_dockerfile_image()
|
||||
|
||||
if [ -f "$dockerfile_path" ]; then
|
||||
info "docker building $image"
|
||||
if ! sudo "${DOCKER_EXE}" build --build-arg http_proxy="${http_proxy}" --build-arg https_proxy="${https_proxy}" --label "$image" --tag "${image}" -f "$dockerfile_path" "$dockerfile_dir"; then
|
||||
if ! sudo -E "${DOCKER_EXE}" build \
|
||||
--build-arg http_proxy="${http_proxy}" --build-arg https_proxy="${https_proxy}" \
|
||||
--build-arg HTTP_PROXY="${http_proxy}" --build-arg HTTPS_PROXY="${https_proxy}" \
|
||||
--label "$image" --tag "${image}" -f "$dockerfile_path" "$dockerfile_dir"; then
|
||||
die "Failed to docker build image $image"
|
||||
fi
|
||||
return 0
|
||||
@ -497,3 +504,7 @@ function get_current_kata_config_file() {
|
||||
|
||||
current_config_file="${KATA_CONFIG_FNAME}"
|
||||
}
|
||||
|
||||
function check_if_root() {
|
||||
[ "$EUID" -ne 0 ] && die "Please run as root or use sudo."
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user