mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-12 10:16:37 +08:00
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:
@@ -17,9 +17,8 @@ RUN --mount=type=cache,target=/go/pkg/mod \
|
|||||||
go mod download
|
go mod download
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN apk add --no-cache curl \
|
RUN apk add --no-cache bash curl \
|
||||||
&& curl -fsSL -o internal/apps/agent/geoipdata/GeoLite2-Country.mmdb \
|
&& bash scripts/fetch-agent-geoip-mmdb.sh
|
||||||
https://raw.githubusercontent.com/Loyalsoldier/geoip/release/GeoLite2-Country.mmdb
|
|
||||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
--mount=type=cache,target=/root/.cache/go-build \
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
go build -trimpath -ldflags "-s -w -X 'github.com/Rain-kl/Wavelet/internal/apps/agent/config.Version=$VERSION'" -o /build/bin/openflare-agent ./cmd/agent/main.go
|
go build -trimpath -ldflags "-s -w -X 'github.com/Rain-kl/Wavelet/internal/apps/agent/config.Version=$VERSION'" -o /build/bin/openflare-agent ./cmd/agent/main.go
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ sidebar: false
|
|||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
- 修复 Agent CI/Docker 构建:`go:embed` 所需的 `GeoLite2-Country.mmdb` 在构建前通过 `scripts/fetch-agent-geoip-mmdb.sh` 自动拉取。
|
- 修复 Agent CI/Docker 构建:将 `GeoLite2-Country.mmdb` 提交至仓库作为兜底,构建前优先尝试 `scripts/fetch-agent-geoip-mmdb.sh` 拉取最新库,远程失败时回退使用已提交文件。
|
||||||
|
|
||||||
## [v2.3.4] - 2026-06-17
|
## [v2.3.4] - 2026-06-17
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -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}"
|
URL="${GEOIP_MMDB_URL:-https://raw.githubusercontent.com/Loyalsoldier/geoip/release/GeoLite2-Country.mmdb}"
|
||||||
|
|
||||||
mkdir -p "$(dirname "$TARGET")"
|
mkdir -p "$(dirname "$TARGET")"
|
||||||
curl -fsSL -o "$TARGET" "$URL"
|
|
||||||
|
|
||||||
if [ ! -s "$TARGET" ]; then
|
if curl -fsSL -o "${TARGET}.tmp" "$URL"; then
|
||||||
echo "downloaded GeoIP database is empty: $TARGET" >&2
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "GeoIP database ready: $TARGET"
|
if [ ! -s "$TARGET" ]; then
|
||||||
|
echo "GeoIP database is empty: $TARGET" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user