Setup proxies in the docker client config to make them available during the "docker build"
@@ -65,3 +65,32 @@ E.g.:
else
echo "Registry certificates and credentials configuration will be skipped"
fi
+
+############################
+# Setup docker client config
+############################
+if [ "$http_proxy" ] || [ "$https_proxy" ] || [ "$no_proxy"]; then
+ echo "Setting Docker client proxies"
+
+_DIND_CLIENT_PROXIES="{
+ \"proxies\":
+ {
+ \"default\":
+ {
+ \"httpProxy\": \"$http_proxy\",
+ \"httpsProxy\": \"$https_proxy\",
+ \"noProxy\": \"$no_proxy\"
+ }
+ }
+}"
+ _DIND_CLIENT_CONFIG_PATH="/root/.docker/config.json"
+ if [ -f "$_DIND_CLIENT_CONFIG_PATH" ]; then
+ _DIND_CLIENT_CONFIG_CONTENTS=$(cat "$_DIND_CLIENT_CONFIG_PATH")
+ else
+ _DIND_CLIENT_CONFIG_CONTENTS="{}"
+ fi
+ _DIND_CLIENT_CONFIG_CONTENTS=$(echo "$_DIND_CLIENT_CONFIG_CONTENTS" | jq -r ". + $_DIND_CLIENT_PROXIES")
+ echo "$_DIND_CLIENT_CONFIG_CONTENTS" > "$_DIND_CLIENT_CONFIG_PATH"
+
+ echo "Proxies written to $_DIND_CLIENT_CONFIG_PATH"
+fi
