mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
fix(ci): fetch GeoLite2 mmdb before agent build
Agent embeds GeoLite2-Country.mmdb but the file is not checked into the repository. Download it in CI, Docker, and Makefile build paths via scripts/fetch-agent-geoip-mmdb.sh, and correct the gitignore exception path for the geoipdata package.
This commit is contained in:
@@ -298,6 +298,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
- name: Fetch embedded GeoIP database
|
||||||
|
run: bash scripts/fetch-agent-geoip-mmdb.sh
|
||||||
|
|
||||||
- name: Build Agent
|
- name: Build Agent
|
||||||
env:
|
env:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
|
|||||||
+1
-1
@@ -77,4 +77,4 @@ profile.cov
|
|||||||
.grok
|
.grok
|
||||||
/.gomodcache/
|
/.gomodcache/
|
||||||
*.mmdb
|
*.mmdb
|
||||||
!openflare_agent/internal/geoipdata/GeoLite2-Country.mmdb
|
!internal/apps/agent/geoipdata/GeoLite2-Country.mmdb
|
||||||
@@ -40,6 +40,7 @@ build-backend:
|
|||||||
|
|
||||||
build-agent:
|
build-agent:
|
||||||
@echo "==> Building agent version=$(VERSION)..."
|
@echo "==> Building agent version=$(VERSION)..."
|
||||||
|
bash scripts/fetch-agent-geoip-mmdb.sh
|
||||||
go build \
|
go build \
|
||||||
-ldflags "-s -w -X '$(MODULE)/internal/apps/agent/config.Version=$(VERSION)'" \
|
-ldflags "-s -w -X '$(MODULE)/internal/apps/agent/config.Version=$(VERSION)'" \
|
||||||
-o bin/openflare-agent \
|
-o bin/openflare-agent \
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ RUN --mount=type=cache,target=/go/pkg/mod \
|
|||||||
go mod download
|
go mod download
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN apk add --no-cache curl \
|
||||||
|
&& curl -fsSL -o internal/apps/agent/geoipdata/GeoLite2-Country.mmdb \
|
||||||
|
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
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ sidebar: false
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
|
||||||
|
- 修复 Agent CI/Docker 构建:`go:embed` 所需的 `GeoLite2-Country.mmdb` 在构建前通过 `scripts/fetch-agent-geoip-mmdb.sh` 自动拉取。
|
||||||
|
|
||||||
## [v2.3.4] - 2026-06-17
|
## [v2.3.4] - 2026-06-17
|
||||||
|
|
||||||
|
|||||||
Executable
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
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
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "GeoIP database ready: $TARGET"
|
||||||
Reference in New Issue
Block a user