diff --git a/Makefile b/Makefile index a1b688ced5a..5d31b2ed88e 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ ANTCTL_BINARY_NAME ?= antctl OVS_VERSION := $(shell head -n 1 build/images/deps/ovs-version) GO_VERSION := $(shell head -n 1 build/images/deps/go-version) CNI_BINARIES_VERSION := $(shell head -n 1 build/images/deps/cni-binaries-version) +BGP_VERSION := $(go list -m all | grep github.com/osrg/gobgp/v3 | cut -d " " -f2 | cut -c 2-) GIT_HOOKS := $(shell find hack/git_client_side_hooks -type f -print) DOCKER_NETWORK ?= default TRIVY_TARGET_IMAGE ?= diff --git a/build/images/base/Dockerfile b/build/images/base/Dockerfile index 9f10ebddc0c..b801b518774 100644 --- a/build/images/base/Dockerfile +++ b/build/images/base/Dockerfile @@ -13,6 +13,27 @@ # limitations under the License. ARG BUILD_TAG + +FROM ubuntu:22.04 AS bgp + +ARG BGP_VERSION + +RUN apt-get update && \ + apt-get install -y --no-install-recommends wget ca-certificates + +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) pluginsArch='amd64' ;; \ + armhf) pluginsArch='arm' ;; \ + arm64) pluginsArch='arm64' ;; \ + *) pluginsArch=''; echo >&2; echo >&2 "unsupported architecture '$dpkgArch'"; echo >&2 ; exit 1 ;; \ + esac; \ + mkdir -p /opt/bgp; \ + wget -q -O - https://github.com/osrg/gobgp/releases/download/v$BGP_VERSION/gobgp_${BGP_VERSION}_linux_${pluginsArch}.tar.gz | tar xz -C /opt/bgp; \ + find /opt/bgp -type f ! -name 'gobgp' -delete + + FROM ubuntu:22.04 AS cni-binaries ARG CNI_BINARIES_VERSION @@ -22,7 +43,6 @@ RUN apt-get update && \ # Leading dot is required for the tar command below ENV CNI_PLUGINS="./host-local ./loopback ./portmap ./bandwidth" - # Download containernetworking plugin binaries for the correct architecture RUN set -eux; \ dpkgArch="$(dpkg --print-architecture)"; \ @@ -57,3 +77,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends ipset jq inotif /iptables-wrapper-installer.sh COPY --from=cni-binaries /opt/cni/bin /opt/cni/bin +COPY --from=bgp /opt/bgp /opt/bgp diff --git a/build/images/base/Dockerfile.ubi b/build/images/base/Dockerfile.ubi index 0c101c89bbd..27bd51b6fd2 100644 --- a/build/images/base/Dockerfile.ubi +++ b/build/images/base/Dockerfile.ubi @@ -13,6 +13,26 @@ # limitations under the License. ARG BUILD_TAG + +FROM ubuntu:22.04 AS bgp + +ARG BGP_VERSION + +RUN apt-get update && \ + apt-get install -y --no-install-recommends wget ca-certificates + +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) pluginsArch='amd64' ;; \ + armhf) pluginsArch='arm' ;; \ + arm64) pluginsArch='arm64' ;; \ + *) pluginsArch=''; echo >&2; echo >&2 "unsupported architecture '$dpkgArch'"; echo >&2 ; exit 1 ;; \ + esac; \ + mkdir -p /opt/bgp; \ + wget -q -O - https://github.com/osrg/gobgp/releases/download/v$BGP_VERSION/gobgp_${BGP_VERSION}_linux_${pluginsArch}.tar.gz | tar xz -C /opt/bgp; \ + find /opt/bgp -type f ! -name 'gobgp' -delete + FROM ubuntu:22.04 AS cni-binaries ARG CNI_BINARIES_VERSION @@ -33,7 +53,7 @@ RUN set -eux; \ *) pluginsArch=''; echo >&2; echo >&2 "unsupported architecture '$dpkgArch'"; echo >&2 ; exit 1 ;; \ esac; \ mkdir -p /opt/cni/bin; \ - wget -q -O - https://github.com/containernetworking/plugins/releases/download/$CNI_BINARIES_VERSION/cni-plugins-linux-${pluginsArch}-$CNI_BINARIES_VERSION.tgz | tar xz -C /opt/cni/bin $CNI_PLUGINS + wget -q -O - https://github.com/containernetworking/plugins/releases/download/$CNI_BINARIES_VERSION/cni-plugins-linux-${pluginsArch}-$CNI_BINARIES_VERSION.tgz | tar xz -C /opt/cni/bin $CNI_PLUGINS; FROM antrea/openvswitch-ubi:${BUILD_TAG} @@ -50,3 +70,4 @@ RUN yum install ipset jq yum-plugin-copr -y && \ yum remove yum-plugin-copr -y && yum clean all COPY --from=cni-binaries /opt/cni/bin /opt/cni/bin +COPY --from=bgp /opt/bgp /opt/bgp diff --git a/build/images/base/build.sh b/build/images/base/build.sh index 10ed579e0f1..eae55d4840e 100755 --- a/build/images/base/build.sh +++ b/build/images/base/build.sh @@ -110,6 +110,7 @@ fi pushd $THIS_DIR > /dev/null CNI_BINARIES_VERSION=$(head -n 1 ../deps/cni-binaries-version) +BGP_VERSION=$(go list -m all | grep github.com/osrg/gobgp/v3 | cut -d " " -f2 | cut -c 2-) SURICATA_VERSION=$(head -n 1 ../deps/suricata-version) BUILD_CACHE_TAG=$(../build-tag.sh) @@ -152,8 +153,7 @@ fi function docker_build_and_push() { local image="$1" local dockerfile="$2" - local build_args="--build-arg CNI_BINARIES_VERSION=$CNI_BINARIES_VERSION --build-arg SURICATA_VERSION=$SURICATA_VERSION --build-arg BUILD_TAG=$BUILD_TAG" - local cache_args="" + local build_args="--build-arg CNI_BINARIES_VERSION=$CNI_BINARIES_VERSION --build-arg BGP_VERSION=$BGP_VERSION --build-arg SURICATA_VERSION=$SURICATA_VERSION --build-arg BUILD_TAG=$BUILD_TAG" if $PUSH; then cache_args="$cache_args --cache-to type=registry,ref=$image-cache:$BUILD_CACHE_TAG,mode=max" fi diff --git a/hack/build-antrea-linux-all.sh b/hack/build-antrea-linux-all.sh index f0eb68dd8d2..5b71ec5face 100755 --- a/hack/build-antrea-linux-all.sh +++ b/hack/build-antrea-linux-all.sh @@ -126,6 +126,7 @@ fi CNI_BINARIES_VERSION=$(head -n 1 build/images/deps/cni-binaries-version) GO_VERSION=$(head -n 1 build/images/deps/go-version) +BGP_VERSION=$(go list -m all | grep github.com/osrg/gobgp/v3 | cut -d " " -f2 | cut -c 2-) if [ "$BUILD_TAG" != "" ]; then ARGS="$ARGS --build-tag $BUILD_TAG"