diff --git a/scripts/start b/scripts/start index 7d1d1925..296477e0 100755 --- a/scripts/start +++ b/scripts/start @@ -19,6 +19,45 @@ if [ "$EUID" -eq 0 ] exit 1 fi +# ── DNS Pre-flight Check ───────────────────────────────────────────── +YELLOW=$'\033[0;33m' +BOLD_YELLOW=$'\033[1;33m' +NC=$'\033[0m' +DNS_TEST_URL="https://dl-cdn.alpinelinux.org" +DNS_MAX_RETRIES=3 +DNS_OK=false +BACKOFF=2 + +echo "Checking Docker DNS connectivity..." +for i in $(seq 1 $DNS_MAX_RETRIES); do + printf " [Attempt $i/$DNS_MAX_RETRIES] Testing resolution... " + if docker run --rm alpine wget --spider --timeout=5 "$DNS_TEST_URL" > /dev/null 2>&1; then + echo "Success" + DNS_OK=true + break + else + echo "Failed" + fi + [ "$i" -lt "$DNS_MAX_RETRIES" ] && sleep $BACKOFF && BACKOFF=$((BACKOFF * 2)) +done + +if [ "$DNS_OK" = false ]; then + cat <&2 + +${BOLD_YELLOW} WARNING: Docker DNS resolution failed after $DNS_MAX_RETRIES attempts.${NC} +${YELLOW} Containers cannot resolve external domains (e.g. dl-cdn.alpinelinux.org). + This is commonly caused by a DNS bridge conflict with systemd-resolved. + + Suggested fixes: + 1. Add DNS to /etc/docker/daemon.json: + { "dns": ["8.8.8.8", "8.8.4.4"] } + 2. Then run sudo systemctl restart docker + + The build will continue, but may fail during package installation.${NC} + +EOF +fi + if [[ ! -d "${NOSTR_CONFIG_DIR}" ]]; then echo "Creating folder ${NOSTR_CONFIG_DIR}" mkdir -p "${NOSTR_CONFIG_DIR}"