Skip to content

Commit

Permalink
Add GoBGP client binary to antrea agent image
Browse files Browse the repository at this point in the history
GoBGP client binary size is ~15MB

Signed-off-by: Rajnish Kumar <[email protected]>
  • Loading branch information
rajnkamr committed Sep 6, 2024
1 parent 29f947c commit 62512e3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
20 changes: 20 additions & 0 deletions build/images/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

ARG BUILD_TAG

FROM ubuntu:22.04 AS cni-binaries

ARG CNI_BINARIES_VERSION
Expand All @@ -35,6 +36,24 @@ RUN set -eux; \
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

FROM ubuntu:22.04 AS gobgp-binary

ARG GOBGP_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$GOBGP_VERSION/gobgp_${GOBGP_VERSION}_linux_${pluginsArch}.tar.gz | tar xz -C /opt/bgp

FROM antrea/openvswitch:${BUILD_TAG}

ARG SURICATA_VERSION
Expand All @@ -57,3 +76,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=gobgp-binary /opt/bgp/gobgp /usr/local/bin
20 changes: 20 additions & 0 deletions build/images/base/Dockerfile.ubi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

ARG BUILD_TAG

FROM ubuntu:22.04 AS cni-binaries

ARG CNI_BINARIES_VERSION
Expand All @@ -35,6 +36,24 @@ RUN set -eux; \
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

FROM ubuntu:22.04 AS gobgp-binary

ARG GOBGP_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$GOBGP_VERSION/gobgp_${GOBGP_VERSION}_linux_${pluginsArch}.tar.gz | tar xz -C /opt/bgp

FROM antrea/openvswitch-ubi:${BUILD_TAG}

ARG SURICATA_VERSION
Expand All @@ -50,3 +69,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=gobgp-binary /opt/bgp/gobgp /usr/local/bin
3 changes: 2 additions & 1 deletion build/images/base/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ pushd $THIS_DIR > /dev/null

CNI_BINARIES_VERSION=$(head -n 1 ../deps/cni-binaries-version)
SURICATA_VERSION=$(head -n 1 ../deps/suricata-version)
GOBGP_VERSION=$(grep "github.com/osrg/gobgp" ../../../go.mod | head -n1 | cut -d " " -f2 | cut -c 2-)

BUILD_CACHE_TAG=$(../build-tag.sh)

Expand Down Expand Up @@ -152,7 +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 build_args="--build-arg CNI_BINARIES_VERSION=$CNI_BINARIES_VERSION --build-arg SURICATA_VERSION=$SURICATA_VERSION --build-arg GOBGP_VERSION=$GOBGP_VERSION --build-arg BUILD_TAG=$BUILD_TAG"
local cache_args=""
if $PUSH; then
cache_args="$cache_args --cache-to type=registry,ref=$image-cache:$BUILD_CACHE_TAG,mode=max"
Expand Down

0 comments on commit 62512e3

Please sign in to comment.