Compare commits

...
1 Commits
Author SHA1 Message Date
Denozordec 1c7152a285 feat(docker): update BIRD build process and documentation
CI / changes (push) Successful in 11s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Has been skipped
CI / go (push) Successful in 1m8s
CI / bird2 (push) Successful in 17s
CI / release (push) Successful in 5m10s
Refined the BIRD build process in the Docker setup by consolidating the source download and extraction steps. Enhanced the `bird-from-source.sh` script to include a fallback mechanism for downloading the BIRD tarball from GitHub if the primary source fails. Updated the README documentation to clarify the build process and provide links to the BIRD source. This improves reliability and user understanding of the setup.
2026-07-01 00:11:16 +07:00
2 changed files with 50 additions and 8 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
| Было | Стало |
|------|--------|
| 8× `go mod download` + 8× `go build` (разные BIN) | 1× download + 1× компиляция всех `cmd/*` |
| 2× сборка BIRD из исходников (api, all) | 1× stage `birdc`, копируется в runtime |
| 2× сборка BIRD из исходников (api, all) | 1× stage `birdc` ([bird-from-source.sh](bird/bird-from-source.sh): [bird.nic.cz/get-bird](https://bird.nic.cz/get-bird/)) |
| 2× `npm ci` (web, web-all) | 1× `web-deps` + 1× `web-build` + два nginx-образа (общий артефакт) |
| 8 runner'ов с checkout/login | 1 job `docker-go`, 1 job `docker-web` |
+49 -7
View File
@@ -1,7 +1,9 @@
#!/bin/sh
# Сборка BIRD из официального tarball (версия задаётся BIRD_VERSION, по умолчанию 2.14).
# Запуск от root (Docker) или через sudo на хосте. Префикс установки: /usr/local.
# birdc требует ncurses + readline; в runtime-образе gobinary — libncurses6 + libreadline8.
# Сборка BIRD из официального tarball (BIRD_VERSION, по умолчанию 2.14).
# Источники: https://bird.nic.cz/get-bird/ (актуальные), https://bird.nic.cz/old-releases/ (архив).
# Tarball: https://bird.nic.cz/download/bird-<version>.tar.gz
# Запуск от root (Docker) или через sudo на хосте. Префикс: /usr/local.
# birdc: ncurses + readline; runtime gobinary — libreadline8 + libncurses6.
set -eu
BIRD_VERSION="${BIRD_VERSION:-2.14}"
export DEBIAN_FRONTEND=noninteractive
@@ -18,14 +20,54 @@ apt-get install -y --no-install-recommends \
cd /tmp
rm -rf "bird-${BIRD_VERSION}"
curl -fsSL "https://bird.network.cz/download/bird-${BIRD_VERSION}.tar.gz" | tar xz
cd "bird-${BIRD_VERSION}"
BIRD_TARBALL="bird-${BIRD_VERSION}.tar.gz"
BIRD_SRC_DIR="bird-${BIRD_VERSION}"
BIRD_NIC_URL="https://bird.nic.cz/download/${BIRD_TARBALL}"
# Старые релизы (2.14 и др.) — только на old-releases; get-bird — для актуальных.
BIRD_REFERER="https://bird.nic.cz/old-releases/"
case "${BIRD_VERSION}" in
2.19.*|2.18.*|2.17.*|3.*) BIRD_REFERER="https://bird.nic.cz/get-bird/" ;;
esac
GITHUB_TAG_URL="https://github.com/CZ-NIC/bird/archive/refs/tags/v${BIRD_VERSION}.tar.gz"
download_bird_tarball() {
if curl -fsSL --retry 3 --retry-delay 2 \
-H "Referer: ${BIRD_REFERER}" \
-H "User-Agent: EvoBGP-docker-build/1.0 (+https://bird.nic.cz/get-bird/)" \
"${BIRD_NIC_URL}" -o "${BIRD_TARBALL}"; then
return 0
fi
echo "bird.nic.cz download failed, trying GitHub mirror (CZ-NIC/bird)..." >&2
curl -fsSL --retry 3 --retry-delay 2 \
-H "User-Agent: EvoBGP-docker-build/1.0" \
"${GITHUB_TAG_URL}" -o "${BIRD_TARBALL}"
}
download_bird_tarball
tar xzf "${BIRD_TARBALL}"
rm -f "${BIRD_TARBALL}"
if [ ! -d "${BIRD_SRC_DIR}" ]; then
# GitHub archive: bird-2.14 → иногда bird-bird-2.14; ищем единственный каталог bird-*.
BIRD_SRC_DIR="$(find /tmp -maxdepth 1 -type d -name 'bird-*' | head -n 1)"
if [ -z "${BIRD_SRC_DIR}" ] || [ ! -d "${BIRD_SRC_DIR}" ]; then
echo "BIRD source directory not found after extract" >&2
exit 1
fi
fi
cd "${BIRD_SRC_DIR}"
if [ ! -f ./configure ]; then
apt-get install -y --no-install-recommends autoconf automake libtool
autoreconf -fi
fi
./configure --prefix=/usr/local --enable-client
make -j"$(nproc)"
make install
cd /
rm -rf "/tmp/bird-${BIRD_VERSION}"
rm -rf "${BIRD_SRC_DIR}"
apt-get purge -y build-essential flex bison libncurses-dev libreadline-dev
apt-get purge -y build-essential flex bison libncurses-dev libreadline-dev autoconf automake libtool 2>/dev/null || \
apt-get purge -y build-essential flex bison libncurses-dev libreadline-dev
apt-get autoremove -y
rm -rf /var/lib/apt/lists/*