feat: update CI configuration and Dockerfiles for improved build efficiency
CI / changes (push) Successful in 7s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 1m29s
CI / docker-web (push) Failing after 15s
CI / docker-bird (push) Failing after 14s
CI / bird2 (push) Successful in 14s
CI / docker-go (push) Failing after 14s

Enhanced the CI workflow by adding support for docker-bake.hcl to streamline the building and pushing of Go images. Updated Go version to 1.24 and introduced caching for Go module dependencies. Refactored Dockerfiles for evobgp-agent, evobgp-web, and gobinary to utilize build stages more effectively, improving caching and build performance. Adjusted installation commands and entry points for better clarity and maintainability.
This commit is contained in:
Denozordec
2026-05-19 10:44:24 +07:00
parent 7a2b015b12
commit 80229b33fc
6 changed files with 349 additions and 204 deletions
+31 -167
View File
@@ -83,6 +83,7 @@ jobs:
deploy/bird/*) bird_conf=true ;;
deploy/docker/bird/*) docker_bird=true; docker_go=true ;;
deploy/docker/gobinary/*) docker_go=true ;;
deploy/docker/docker-bake.hcl) docker_go=true; docker_web=true ;;
deploy/docker/evobgp-agent/*) docker_go=true ;;
deploy/docker/evobgp-web/*) docker_web=true ;;
deploy/docker/bird2/*) docker_bird=true ;;
@@ -129,7 +130,9 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.24"
cache: true
cache-dependency-path: go.sum
- name: Vet
run: go vet ./...
- name: Test
@@ -183,14 +186,10 @@ jobs:
done
# ---------------------------------------------------------------------------
# Docker: Go-бинарники (api, all, scheduler, ingest, render, deploy, node, agent).
# Запускается если изменился Go-код или Go-Dockerfile.
# Если Go-код менялся — требуем успех go-тестов; если только Dockerfile — go skipped, ОК.
#
# docker-go-prime: один раз собирает stage `deps` (go mod download) и пишет BuildKit cache
# в registry — матрица docker-go не качает модули восемь раз подряд.
# Docker: все Go-образы одним buildx bake (один go mod download, одна компиляция cmd/*,
# birdc собирается один раз для api/all). Registry cache: evobgp-buildcache:go-buildcache.
# ---------------------------------------------------------------------------
docker-go-prime:
docker-go:
needs: [changes, go]
if: >-
always() &&
@@ -200,91 +199,6 @@ jobs:
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') &&
(needs.changes.outputs.go == 'true' || needs.changes.outputs.docker_go == 'true')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare image metadata
id: meta
run: |
set -euo pipefail
owner_lc="$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')"
echo "owner_lc=$owner_lc" >> "$GITHUB_OUTPUT"
- name: Log in to Gitea Registry
uses: docker/login-action@v3
with:
registry: git.shts.su
username: ${{ gitea.actor }}
password: ${{ secrets.ACTIONS_PAT || gitea.token }}
- name: Prime Go module layer (deps)
env:
OWNER_LC: ${{ steps.meta.outputs.owner_lc }}
run: |
set -euxo pipefail
WS="${{ github.workspace }}"
CACHE_REF="git.shts.su/${OWNER_LC}/evobgp-buildcache:go-buildcache"
cd "$WS"
docker buildx build \
--platform linux/amd64 \
--file deploy/docker/gobinary/Dockerfile \
--target deps \
--cache-from "type=registry,ref=${CACHE_REF}" \
--cache-to "type=registry,ref=${CACHE_REF},mode=max" \
"$WS"
docker-go:
needs: [changes, go, docker-go-prime]
if: >-
always() &&
needs.changes.result == 'success' &&
needs.go.result != 'failure' &&
needs.docker-go-prime.result == 'success' &&
github.event_name == 'push' &&
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') &&
(needs.changes.outputs.go == 'true' || needs.changes.outputs.docker_go == 'true')
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- image: evobgp-api
dockerfile: deploy/docker/gobinary/Dockerfile
bin: evobgp-api
birdc: "1"
evobgp_upstream: ""
- image: evobgp-all
dockerfile: deploy/docker/gobinary/Dockerfile
bin: evobgp-all
birdc: "1"
evobgp_upstream: ""
- image: evobgp-scheduler
dockerfile: deploy/docker/gobinary/Dockerfile
bin: evobgp-scheduler
birdc: "0"
evobgp_upstream: ""
- image: evobgp-ingest
dockerfile: deploy/docker/gobinary/Dockerfile
bin: evobgp-ingest
birdc: "0"
evobgp_upstream: ""
- image: evobgp-render
dockerfile: deploy/docker/gobinary/Dockerfile
bin: evobgp-render
birdc: "0"
evobgp_upstream: ""
- image: evobgp-deploy
dockerfile: deploy/docker/gobinary/Dockerfile
bin: evobgp-deploy
birdc: "0"
evobgp_upstream: ""
- image: evobgp-node
dockerfile: deploy/docker/gobinary/Dockerfile
bin: evobgp-node
birdc: "0"
evobgp_upstream: ""
- image: evobgp-agent
dockerfile: deploy/docker/evobgp-agent/Dockerfile
evobgp_upstream: ""
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
@@ -303,46 +217,23 @@ jobs:
registry: git.shts.su
username: ${{ gitea.actor }}
password: ${{ secrets.ACTIONS_PAT || gitea.token }}
- name: Build and push ${{ matrix.image }}
- name: Build and push Go images (bake)
env:
OWNER_LC: ${{ steps.meta.outputs.owner_lc }}
SHORT_SHA: ${{ steps.meta.outputs.short_sha }}
DF: ${{ matrix.dockerfile }}
IMAGE: ${{ matrix.image }}
BIN: ${{ matrix.bin }}
BIRDC: ${{ matrix.birdc }}
EVOBGP_UPSTREAM: ${{ matrix.evobgp_upstream }}
run: |
set -euxo pipefail
WS="${{ github.workspace }}"
cd "$WS"
CACHE_REF="git.shts.su/${OWNER_LC}/evobgp-buildcache:go-buildcache"
IMG="git.shts.su/${OWNER_LC}/${IMAGE}"
BUILD_ARGS=()
if [ -n "${BIN:-}" ]; then
BUILD_ARGS+=(--build-arg "BIN=${BIN}")
BUILD_ARGS+=(--build-arg "INSTALL_BIRDC=${BIRDC:-0}")
fi
if [ -n "${EVOBGP_UPSTREAM:-}" ]; then
BUILD_ARGS+=(--build-arg "EVOBGP_UPSTREAM=${EVOBGP_UPSTREAM}")
fi
docker buildx build \
--platform linux/amd64 \
--file "$DF" \
"${BUILD_ARGS[@]}" \
--cache-from "type=registry,ref=${CACHE_REF}" \
--cache-to "type=registry,ref=${CACHE_REF},mode=max" \
--tag "${IMG}:latest" \
--tag "${IMG}:${SHORT_SHA}" \
--tag "${IMG}:sha-${{ github.sha }}" \
cd "${{ github.workspace }}/deploy/docker"
docker buildx bake -f docker-bake.hcl go-images \
--push \
"$WS"
--set "*.REGISTRY=git.shts.su/${OWNER_LC}" \
--set "*.IMAGE_TAG=latest" \
--set "*.SHORT_SHA=${SHORT_SHA}" \
--set "*.SHA_FULL=${{ github.sha }}" \
--set "*.CACHE_REF_GO=git.shts.su/${OWNER_LC}/evobgp-buildcache:go-buildcache"
# ---------------------------------------------------------------------------
# Docker: Web-фронтенд (evobgp-web, evobgp-web-all).
# Не зависит от Go-тестов — SvelteKit собирается отдельно.
# Docker: Web (evobgp-web, evobgp-web-all) — один npm ci (кэш) + два nginx-тега.
# ---------------------------------------------------------------------------
docker-web:
needs: [changes]
@@ -351,16 +242,6 @@ jobs:
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') &&
(needs.changes.outputs.web == 'true' || needs.changes.outputs.docker_web == 'true')
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- image: evobgp-web
dockerfile: deploy/docker/evobgp-web/Dockerfile
evobgp_upstream: ""
- image: evobgp-web-all
dockerfile: deploy/docker/evobgp-web/Dockerfile
evobgp_upstream: evobgp-all
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
@@ -379,33 +260,20 @@ jobs:
registry: git.shts.su
username: ${{ gitea.actor }}
password: ${{ secrets.ACTIONS_PAT || gitea.token }}
- name: Build and push ${{ matrix.image }}
- name: Build and push Web images (bake)
env:
OWNER_LC: ${{ steps.meta.outputs.owner_lc }}
SHORT_SHA: ${{ steps.meta.outputs.short_sha }}
DF: ${{ matrix.dockerfile }}
IMAGE: ${{ matrix.image }}
EVOBGP_UPSTREAM: ${{ matrix.evobgp_upstream }}
run: |
set -euxo pipefail
WS="${{ github.workspace }}"
cd "$WS"
IMG="git.shts.su/${OWNER_LC}/${IMAGE}"
BUILD_ARGS=()
if [ -n "${EVOBGP_UPSTREAM:-}" ]; then
BUILD_ARGS+=(--build-arg "EVOBGP_UPSTREAM=${EVOBGP_UPSTREAM}")
fi
docker buildx build \
--platform linux/amd64 \
--file "$DF" \
"${BUILD_ARGS[@]}" \
--tag "${IMG}:latest" \
--tag "${IMG}:${SHORT_SHA}" \
--tag "${IMG}:sha-${{ github.sha }}" \
cd "${{ github.workspace }}/deploy/docker"
docker buildx bake -f docker-bake.hcl web-images \
--push \
"$WS"
--set "*.REGISTRY=git.shts.su/${OWNER_LC}" \
--set "*.IMAGE_TAG=latest" \
--set "*.SHORT_SHA=${SHORT_SHA}" \
--set "*.SHA_FULL=${{ github.sha }}" \
--set "*.CACHE_REF_WEB=git.shts.su/${OWNER_LC}/evobgp-buildcache:web-buildcache"
# ---------------------------------------------------------------------------
# Docker: BIRD2 (evobgp-bird2).
@@ -436,20 +304,16 @@ jobs:
registry: git.shts.su
username: ${{ gitea.actor }}
password: ${{ secrets.ACTIONS_PAT || gitea.token }}
- name: Build and push evobgp-bird2
- name: Build and push evobgp-bird2 (bake)
env:
OWNER_LC: ${{ steps.meta.outputs.owner_lc }}
SHORT_SHA: ${{ steps.meta.outputs.short_sha }}
run: |
set -euxo pipefail
WS="${{ github.workspace }}"
IMG="git.shts.su/${OWNER_LC}/evobgp-bird2"
docker buildx build \
--platform linux/amd64 \
--file deploy/docker/bird2/Dockerfile \
--tag "${IMG}:latest" \
--tag "${IMG}:${SHORT_SHA}" \
--tag "${IMG}:sha-${{ github.sha }}" \
cd "${{ github.workspace }}/deploy/docker"
docker buildx bake -f docker-bake.hcl evobgp-bird2 \
--push \
"$WS"
--set "*.REGISTRY=git.shts.su/${OWNER_LC}" \
--set "*.IMAGE_TAG=latest" \
--set "*.SHORT_SHA=${SHORT_SHA}" \
--set "*.SHA_FULL=${{ github.sha }}"