Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions scripts/start
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF >&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
Comment on lines +44 to +59
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this message go to stderr?
should we use HEREDOC for the multiline message?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great points. Sending the warning to stderr is definitely better practice for diagnostic messages, and using a HEREDOC would be a cleaner approach . I'll refactor the block using cat <&2 to address both. Pushing the update shortly !


if [[ ! -d "${NOSTR_CONFIG_DIR}" ]]; then
echo "Creating folder ${NOSTR_CONFIG_DIR}"
mkdir -p "${NOSTR_CONFIG_DIR}"
Expand Down