@@ -20,29 +20,42 @@ if [ "$EUID" -eq 0 ]
2020fi
2121
2222# ── DNS Pre-flight Check ─────────────────────────────────────────────
23- echo " Checking Docker DNS connectivity..."
23+ YELLOW=$' \033 [0;33m'
24+ BOLD_YELLOW=$' \033 [1;33m'
25+ NC=$' \033 [0m'
26+ DNS_TEST_URL=" https://dl-cdn.alpinelinux.org"
27+ DNS_MAX_RETRIES=3
2428DNS_OK=false
25- for i in 1 2 3; do
26- if docker run --rm alpine wget --spider --timeout=5 https://dl-cdn.alpinelinux.org > /dev/null 2>&1 ; then
29+ BACKOFF=2
30+
31+ echo " Checking Docker DNS connectivity..."
32+ for i in $( seq 1 $DNS_MAX_RETRIES ) ; do
33+ printf " [Attempt $i /$DNS_MAX_RETRIES ] Testing resolution... "
34+ if docker run --rm alpine wget --spider --timeout=5 " $DNS_TEST_URL " > /dev/null 2>&1 ; then
35+ echo " Success"
2736 DNS_OK=true
2837 break
38+ else
39+ echo " Failed"
2940 fi
30- [ " $i " -lt 3 ] && sleep 2
41+ [ " $i " -lt " $DNS_MAX_RETRIES " ] && sleep $BACKOFF && BACKOFF= $(( BACKOFF * 2 ))
3142done
3243
3344if [ " $DNS_OK " = false ]; then
34- echo " "
35- echo -e " \033[1;33m WARNING: Docker DNS resolution failed after 3 attempts.\033[0m"
36- echo -e " \033[0;33m Containers cannot resolve external domains (e.g. dl-cdn.alpinelinux.org)."
37- echo " This is commonly caused by a DNS bridge conflict with systemd-resolved."
38- echo " "
39- echo " Suggested fixes:"
40- echo " 1. Add DNS to /etc/docker/daemon.json:"
41- echo ' { "dns": ["8.8.8.8", "8.8.4.4"] }'
42- echo " 2. Then run sudo systemctl restart docker"
43- echo " "
44- echo -e " The build will continue, but may fail during package installation.\033[0m"
45- echo " "
45+ cat << EOF >&2
46+
47+ ${BOLD_YELLOW} WARNING: Docker DNS resolution failed after $DNS_MAX_RETRIES attempts.${NC}
48+ ${YELLOW} Containers cannot resolve external domains (e.g. dl-cdn.alpinelinux.org).
49+ This is commonly caused by a DNS bridge conflict with systemd-resolved.
50+
51+ Suggested fixes:
52+ 1. Add DNS to /etc/docker/daemon.json:
53+ { "dns": ["8.8.8.8", "8.8.4.4"] }
54+ 2. Then run sudo systemctl restart docker
55+
56+ The build will continue, but may fail during package installation.${NC}
57+
58+ EOF
4659fi
4760
4861if [[ ! -d " ${NOSTR_CONFIG_DIR} " ]]; then
0 commit comments