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.
50 lines
1.9 KiB
Docker
50 lines
1.9 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
# Универсальная сборка бинарей cmd/* (ARG BIN) или всех сразу (target build-all).
|
|
# INSTALL_BIRDC=1 — birdc из stage birdc (собирается один раз, переиспользуется api/all).
|
|
# CI: docker buildx bake -f deploy/docker/docker-bake.hcl
|
|
FROM public.ecr.aws/docker/library/golang:1.24-bookworm AS deps
|
|
WORKDIR /src
|
|
COPY go.mod go.sum ./
|
|
RUN --mount=type=cache,target=/go/pkg/mod,sharing=locked \
|
|
go mod download
|
|
|
|
FROM deps AS build-all
|
|
COPY . .
|
|
RUN --mount=type=cache,target=/go/pkg/mod,sharing=locked \
|
|
--mount=type=cache,target=/root/.cache/go-build,sharing=locked \
|
|
set -eux; \
|
|
mkdir -p /out; \
|
|
for d in cmd/*/; do \
|
|
name="$(basename "$d")"; \
|
|
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o "/out/${name}" "./cmd/${name}"; \
|
|
done
|
|
|
|
# Один бинарь (локальная сборка); в CI — build-all + runtime.
|
|
FROM deps AS build
|
|
COPY . .
|
|
ARG BIN=evobgp-api
|
|
RUN --mount=type=cache,target=/go/pkg/mod,sharing=locked \
|
|
--mount=type=cache,target=/root/.cache/go-build,sharing=locked \
|
|
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/evobgp "./cmd/${BIN}"
|
|
|
|
FROM public.ecr.aws/docker/library/debian:bookworm-slim AS birdc
|
|
ARG BIRD_VERSION=2.14
|
|
COPY deploy/docker/bird/bird-from-source.sh /tmp/bird-from-source.sh
|
|
RUN chmod +x /tmp/bird-from-source.sh \
|
|
&& BIRD_VERSION="${BIRD_VERSION}" /tmp/bird-from-source.sh \
|
|
&& rm -f /tmp/bird-from-source.sh
|
|
|
|
FROM public.ecr.aws/docker/library/debian:bookworm-slim AS runtime-base
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
FROM runtime-base AS runtime
|
|
ARG BIN=evobgp-api
|
|
COPY --from=build-all /out/${BIN} /usr/local/bin/evobgp
|
|
EXPOSE 8080
|
|
ENTRYPOINT ["/usr/local/bin/evobgp"]
|
|
|
|
FROM runtime AS runtime-birdc
|
|
COPY --from=birdc /usr/local/sbin/bird /usr/local/sbin/birdc /usr/local/sbin/
|