fix(agent): commit GeoLite2 mmdb as build fallback

Vendor GeoLite2-Country.mmdb in the repository so agent builds still
work when the remote download is unavailable. Update the fetch script
and agent Dockerfile to prefer a fresh download and fall back to the
committed database file.
This commit is contained in:
ryan
2026-06-20 14:04:42 +08:00
parent 3a368119e5
commit 570b639e07
4 changed files with 16 additions and 8 deletions
+13 -4
View File
@@ -6,11 +6,20 @@ TARGET="${ROOT}/internal/apps/agent/geoipdata/GeoLite2-Country.mmdb"
URL="${GEOIP_MMDB_URL:-https://raw.githubusercontent.com/Loyalsoldier/geoip/release/GeoLite2-Country.mmdb}"
mkdir -p "$(dirname "$TARGET")"
curl -fsSL -o "$TARGET" "$URL"
if [ ! -s "$TARGET" ]; then
echo "downloaded GeoIP database is empty: $TARGET" >&2
if curl -fsSL -o "${TARGET}.tmp" "$URL"; then
mv "${TARGET}.tmp" "$TARGET"
echo "GeoIP database downloaded: $TARGET"
elif [ -s "$TARGET" ]; then
rm -f "${TARGET}.tmp"
echo "GeoIP download failed, using committed database: $TARGET"
else
rm -f "${TARGET}.tmp"
echo "GeoIP database missing and download failed: $URL" >&2
exit 1
fi
echo "GeoIP database ready: $TARGET"
if [ ! -s "$TARGET" ]; then
echo "GeoIP database is empty: $TARGET" >&2
exit 1
fi