From 36109e71f5f9a573c3366154d9442ed1ded21228 Mon Sep 17 00:00:00 2001 From: Antonin Bas Date: Thu, 8 Dec 2022 15:43:48 -0800 Subject: [PATCH] Upgrade Antrea base image to ubuntu:22.04 Ubuntu 20.04 comes with iptables 1.8.4, which seems to have several bugs when used with nft. In particular, we observe that iptables-restore sometimes segfaults when restoring the ANTREA-NODE-PORT-LOCAL chain in the nat table. Ubuntu 22.04 comes with a more recent iptables version, 1.8.7. As part of this change, we change the tag format for base images (antrea/openvswitch and antrea/base-ubuntu). We no longer use the OVS version as the tag, instead we use the Antrea minor version number. Fixes #4435 Signed-off-by: Antonin Bas --- Makefile | 4 ++- build/images/Dockerfile.build.coverage | 4 +-- build/images/Dockerfile.build.ubi | 4 +-- build/images/Dockerfile.build.ubuntu | 4 +-- build/images/Dockerfile.ubuntu | 18 ++++++++-- build/images/base/Dockerfile | 20 +++++++++-- build/images/base/Dockerfile.ubi | 20 +++++++++-- build/images/base/build.sh | 35 ++++++++++---------- build/images/build-tag.sh | 27 +++++++++++++++ build/images/ovs/Dockerfile | 22 +++++++++--- build/images/ovs/README.md | 17 ++++------ build/images/ovs/apply-patches.sh | 6 ++-- build/images/ovs/build.sh | 46 ++++++++++++++------------ build/images/test/Dockerfile | 18 ++++++++-- hack/build-antrea-linux-all.sh | 28 ++++++++-------- 15 files changed, 186 insertions(+), 87 deletions(-) create mode 100755 build/images/build-tag.sh diff --git a/Makefile b/Makefile index e0bdb7624e9..06e91d9bb7d 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,11 @@ DOCKER_CACHE := $(CURDIR)/.cache 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) +BUILD_TAG := $(shell build/images/build-tag.sh) -DOCKER_BUILD_ARGS = --build-arg OVS_VERSION=$(OVS_VERSION) +DOCKER_BUILD_ARGS := --build-arg OVS_VERSION=$(OVS_VERSION) DOCKER_BUILD_ARGS += --build-arg GO_VERSION=$(GO_VERSION) +DOCKER_BUILD_ARGS += --build-arg BUILD_TAG=$(BUILD_TAG) .PHONY: all all: build diff --git a/build/images/Dockerfile.build.coverage b/build/images/Dockerfile.build.coverage index dd9869bfb99..6d86c4dcb07 100644 --- a/build/images/Dockerfile.build.coverage +++ b/build/images/Dockerfile.build.coverage @@ -1,5 +1,5 @@ ARG GO_VERSION -ARG OVS_VERSION +ARG BUILD_TAG FROM golang:${GO_VERSION} as antrea-build WORKDIR /antrea @@ -13,7 +13,7 @@ COPY . /antrea RUN make antrea-agent antrea-controller antrea-cni antctl-linux antrea-controller-instr-binary antrea-agent-instr-binary antctl-instr-binary RUN mv bin/antctl-linux bin/antctl -FROM antrea/base-ubuntu:${OVS_VERSION} +FROM antrea/base-ubuntu:${BUILD_TAG} LABEL maintainer="Antrea " LABEL description="The Docker image to deploy the Antrea CNI with code coverage measurement enabled (used for testing)." diff --git a/build/images/Dockerfile.build.ubi b/build/images/Dockerfile.build.ubi index 29cbb8132bc..7eb3356c963 100644 --- a/build/images/Dockerfile.build.ubi +++ b/build/images/Dockerfile.build.ubi @@ -1,5 +1,5 @@ ARG GO_VERSION -ARG OVS_VERSION +ARG BUILD_TAG FROM golang:${GO_VERSION} as antrea-build WORKDIR /antrea @@ -13,7 +13,7 @@ COPY . /antrea RUN make antrea-agent antrea-controller antrea-cni antctl-linux RUN mv bin/antctl-linux bin/antctl -FROM antrea/base-ubi:${OVS_VERSION} +FROM antrea/base-ubi:${BUILD_TAG} LABEL maintainer="Antrea " LABEL description="The Docker image to deploy the Antrea CNI. " diff --git a/build/images/Dockerfile.build.ubuntu b/build/images/Dockerfile.build.ubuntu index cb25d626ece..cad5dd09e7a 100644 --- a/build/images/Dockerfile.build.ubuntu +++ b/build/images/Dockerfile.build.ubuntu @@ -1,5 +1,5 @@ ARG GO_VERSION -ARG OVS_VERSION +ARG BUILD_TAG FROM golang:${GO_VERSION} as antrea-build WORKDIR /antrea @@ -13,7 +13,7 @@ COPY . /antrea RUN make antrea-agent antrea-controller antrea-cni antctl-linux RUN mv bin/antctl-linux bin/antctl -FROM antrea/base-ubuntu:${OVS_VERSION} +FROM antrea/base-ubuntu:${BUILD_TAG} LABEL maintainer="Antrea " LABEL description="The Docker image to deploy the Antrea CNI." diff --git a/build/images/Dockerfile.ubuntu b/build/images/Dockerfile.ubuntu index f3e4660fc6c..05db9e4ab77 100644 --- a/build/images/Dockerfile.ubuntu +++ b/build/images/Dockerfile.ubuntu @@ -1,5 +1,19 @@ -ARG OVS_VERSION -FROM antrea/base-ubuntu:${OVS_VERSION} +# Copyright 2022 Antrea Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG BUILD_TAG +FROM antrea/base-ubuntu:${BUILD_TAG} LABEL maintainer="Antrea " LABEL description="The Docker image to deploy the Antrea CNI." diff --git a/build/images/base/Dockerfile b/build/images/base/Dockerfile index d11b03a89e3..9ae2e1538fe 100644 --- a/build/images/base/Dockerfile +++ b/build/images/base/Dockerfile @@ -1,5 +1,19 @@ -ARG OVS_VERSION -FROM ubuntu:20.04 as cni-binaries +# Copyright 2022 Antrea Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG BUILD_TAG +FROM ubuntu:22.04 as cni-binaries ARG CNI_BINARIES_VERSION ARG WHEREABOUTS_VERSION=v0.5.1 @@ -23,7 +37,7 @@ RUN set -eux; \ 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 /opt/cni/bin/whereabouts https://github.com/k8snetworkplumbingwg/whereabouts/releases/download/$WHEREABOUTS_VERSION/whereabouts-${pluginsArch} && chmod +x /opt/cni/bin/whereabouts -FROM antrea/openvswitch:${OVS_VERSION} +FROM antrea/openvswitch:${BUILD_TAG} LABEL maintainer="Antrea " LABEL description="An Ubuntu based Docker base image for Antrea." diff --git a/build/images/base/Dockerfile.ubi b/build/images/base/Dockerfile.ubi index 23dce6af5d8..ee03fa1a498 100644 --- a/build/images/base/Dockerfile.ubi +++ b/build/images/base/Dockerfile.ubi @@ -1,5 +1,19 @@ -ARG OVS_VERSION -FROM ubuntu:20.04 as cni-binaries +# Copyright 2022 Antrea Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG BUILD_TAG +FROM ubuntu:22.04 as cni-binaries ARG CNI_BINARIES_VERSION ARG WHEREABOUTS_VERSION=v0.5.1 @@ -23,7 +37,7 @@ RUN set -eux; \ 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 /opt/cni/bin/whereabouts https://github.com/k8snetworkplumbingwg/whereabouts/releases/download/$WHEREABOUTS_VERSION/whereabouts-${pluginsArch} && chmod +x /opt/cni/bin/whereabouts -FROM antrea/openvswitch-ubi:${OVS_VERSION} +FROM antrea/openvswitch-ubi:${BUILD_TAG} LABEL maintainer="Antrea " LABEL description="An UBI8 based Docker base image for Antrea." diff --git a/build/images/base/build.sh b/build/images/base/build.sh index 1348242b169..7f16ce987f5 100755 --- a/build/images/base/build.sh +++ b/build/images/base/build.sh @@ -24,7 +24,7 @@ function echoerr { } _usage="Usage: $0 [--pull] [--push] [--platform ] [--distro [ubuntu|ubi]] -Build the antrea/base-ubuntu: image. +Build the antrea base image. --pull Always attempt to pull a newer version of the base images --push Push the built image to the registry --platform Target platform for the image if server is multi-platform capable @@ -90,28 +90,29 @@ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" pushd $THIS_DIR > /dev/null -OVS_VERSION=$(head -n 1 ../deps/ovs-version) CNI_BINARIES_VERSION=$(head -n 1 ../deps/cni-binaries-version) +BUILD_TAG=$(../build-tag.sh) + if $PULL; then if [[ ${DOCKER_REGISTRY} == "" ]]; then - docker pull $PLATFORM_ARG ubuntu:20.04 + docker pull $PLATFORM_ARG ubuntu:22.04 else - docker pull ${DOCKER_REGISTRY}/antrea/ubuntu:20.04 - docker tag ${DOCKER_REGISTRY}/antrea/ubuntu:20.04 ubuntu:20.04 + docker pull ${DOCKER_REGISTRY}/antrea/ubuntu:22.04 + docker tag ${DOCKER_REGISTRY}/antrea/ubuntu:22.04 ubuntu:22.04 fi if [ "$DISTRO" == "ubuntu" ]; then IMAGES_LIST=( - "antrea/openvswitch:$OVS_VERSION" + "antrea/openvswitch:$BUILD_TAG" "antrea/cni-binaries:$CNI_BINARIES_VERSION" - "antrea/base-ubuntu:$OVS_VERSION" + "antrea/base-ubuntu:$BUILD_TAG" ) elif [ "$DISTRO" == "ubi" ]; then IMAGES_LIST=( - "antrea/openvswitch-ubi:$OVS_VERSION" + "antrea/openvswitch-ubi:$BUILD_TAG" "antrea/cni-binaries:$CNI_BINARIES_VERSION" - "antrea/base-ubi:$OVS_VERSION" + "antrea/base-ubi:$BUILD_TAG" ) fi for image in "${IMAGES_LIST[@]}"; do @@ -131,28 +132,28 @@ docker build $PLATFORM_ARG --target cni-binaries \ --cache-from antrea/cni-binaries:$CNI_BINARIES_VERSION \ -t antrea/cni-binaries:$CNI_BINARIES_VERSION \ --build-arg CNI_BINARIES_VERSION=$CNI_BINARIES_VERSION \ - --build-arg OVS_VERSION=$OVS_VERSION . + --build-arg BUILD_TAG=$BUILD_TAG . if [ "$DISTRO" == "ubuntu" ]; then docker build $PLATFORM_ARG \ --cache-from antrea/cni-binaries:$CNI_BINARIES_VERSION \ - --cache-from antrea/base-ubuntu:$OVS_VERSION \ - -t antrea/base-ubuntu:$OVS_VERSION \ + --cache-from antrea/base-ubuntu:$BUILD_TAG \ + -t antrea/base-ubuntu:$BUILD_TAG \ --build-arg CNI_BINARIES_VERSION=$CNI_BINARIES_VERSION \ - --build-arg OVS_VERSION=$OVS_VERSION . + --build-arg BUILD_TAG=$BUILD_TAG . elif [ "$DISTRO" == "ubi" ]; then docker build $PLATFORM_ARG \ --cache-from antrea/cni-binaries:$CNI_BINARIES_VERSION \ - --cache-from antrea/base-ubuntu:$OVS_VERSION \ - -t antrea/base-ubi:$OVS_VERSION \ + --cache-from antrea/base-ubi:$BUILD_TAG \ + -t antrea/base-ubi:$BUILD_TAG \ -f Dockerfile.ubi \ --build-arg CNI_BINARIES_VERSION=$CNI_BINARIES_VERSION \ - --build-arg OVS_VERSION=$OVS_VERSION . + --build-arg BUILD_TAG=$BUILD_TAG . fi if $PUSH; then docker push antrea/cni-binaries:$CNI_BINARIES_VERSION - docker push antrea/base-$DISTRO:$OVS_VERSION + docker push antrea/base-$DISTRO:$BUILD_TAG fi popd > /dev/null diff --git a/build/images/build-tag.sh b/build/images/build-tag.sh new file mode 100755 index 00000000000..0f8cc05d98a --- /dev/null +++ b/build/images/build-tag.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# Copyright 2022 Antrea Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# build_tag is used to generate the tag for all the base images +# (e.g. antrea/openvswitch) used as part of the build chain to produce the +# Antrea (Linux) images. +function build_tag() { + local this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + local antrea_version=$(head -n 1 $this_dir/../../VERSION | cut -f1,2 -d'.') + local tag="antrea-${antrea_version}" + echo "$tag" +} + +echo "$(build_tag "$@")" diff --git a/build/images/ovs/Dockerfile b/build/images/ovs/Dockerfile index e37d2564f23..ae50e7f4de2 100644 --- a/build/images/ovs/Dockerfile +++ b/build/images/ovs/Dockerfile @@ -1,4 +1,18 @@ -FROM ubuntu:20.04 as ovs-debs +# Copyright 2022 Antrea Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM ubuntu:22.04 as ovs-debs # Some patches may not apply cleanly if a non-default version is provided. # See build/images/deps/ovs-version for the default version. @@ -25,10 +39,10 @@ RUN wget -q -O - https://www.openvswitch.org/releases/openvswitch-$OVS_VERSION.t cd / && rm -rf /tmp/openvswitch* -FROM ubuntu:20.04 +FROM ubuntu:22.04 LABEL maintainer="Antrea " -LABEL description="A Docker image based on Ubuntu 20.04 which includes Open vSwitch built from source." +LABEL description="A Docker image based on Ubuntu 22.04 which includes Open vSwitch built from source." COPY --from=ovs-debs /tmp/ovs-debs/* /tmp/ovs-debs/ COPY charon-logging.conf /tmp @@ -39,7 +53,7 @@ COPY charon-logging.conf /tmp # final image. RUN apt-get update && \ apt-get install -y --no-install-recommends iptables logrotate libstrongswan-standard-plugins && \ - (dpkg -i /tmp/ovs-debs/*.deb || apt-get -f -y --no-install-recommends install) && \ + apt-get -f -y --no-install-recommends install /tmp/ovs-debs/*.deb && \ rm -rf /var/cache/apt/* /var/lib/apt/lists/* && \ sed -i "/rotate /a\ #size 100M" /etc/logrotate.d/openvswitch-switch && \ sed -i "/^.*filelog.*{/r /tmp/charon-logging.conf" /etc/strongswan.d/charon-logging.conf && \ diff --git a/build/images/ovs/README.md b/build/images/ovs/README.md index 455e4b8b16b..533fc957943 100644 --- a/build/images/ovs/README.md +++ b/build/images/ovs/README.md @@ -2,14 +2,13 @@ This directory contains utilities to build a Docker image which includes Open vSwitch (OVS) built from source. We build OVS from source because some features -of Antrea (such as IPsec) require a recent version of OVS, more recent than the -version included in Ubuntu 20.04. The built image is then used as the base image -for the Antrea main Docker image. +of Antrea (such as IPsec) may require a recent version of OVS, more recent than +the version included in the base distribution. The built image is then used as +the base image for the Antrea main Docker image. -The image is re-built and pushed to Dockerhub periodically (every 12 hours) by a -[Github workflow](/.github/workflows/update_ovs_image.yml). Therefore, there -should be no need to update the registry image manually. If it's needed for any -reason, you can follow the instructions below. +The image is re-built and pushed to Dockerhub every time the main branch is +updated. Therefore, there should be no need to update the registry image +manually. If it's needed for any reason, you can follow the instructions below. ## Manually building the image and pushing it to Dockerhub @@ -18,9 +17,5 @@ cd build/images/ovs ./build.sh --pull --push ``` -The image will be pushed to Dockerhub as `antrea/openvswitch:`. The -OVS version used is determined by the contents of the -`build/images/deps/ovs-version` file. - The script will fail if you do not have permission to push to the `antrea` Dockerhub repository. diff --git a/build/images/ovs/apply-patches.sh b/build/images/ovs/apply-patches.sh index 3d3bead5078..eb70265e2e2 100755 --- a/build/images/ovs/apply-patches.sh +++ b/build/images/ovs/apply-patches.sh @@ -100,7 +100,7 @@ if version_lt "$OVS_VERSION" "2.18.0" ; then fi # OVS hardcodes the installation path to /usr/lib/python3.7/dist-packages/ but this location -# does not seem to be in the Python path in Ubuntu 20.04. There may be a better way to do this, +# does not seem to be in the Python path in Ubuntu 22.04. There may be a better way to do this, # but this seems like an acceptable workaround. -sed -i 's/python3\.7/python3\.8/' debian/openvswitch-test.install -sed -i 's/python3\.7/python3\.8/' debian/python3-openvswitch.install +sed -i 's/python3\.7/python3\.10/' debian/openvswitch-test.install +sed -i 's/python3\.7/python3\.10/' debian/python3-openvswitch.install diff --git a/build/images/ovs/build.sh b/build/images/ovs/build.sh index 3e09006db13..4dc13c81c48 100755 --- a/build/images/ovs/build.sh +++ b/build/images/ovs/build.sh @@ -24,7 +24,7 @@ function echoerr { } _usage="Usage: $0 [--pull] [--push] [--platform ] [--distro [ubuntu|ubi]] -Build the antrea/base-ubuntu: image. +Build the antrea openvswitch image. --pull Always attempt to pull a newer version of the base images --push Push the built image to the registry --platform Target platform for the image if server is multi-platform capable @@ -92,6 +92,8 @@ pushd $THIS_DIR > /dev/null OVS_VERSION=$(head -n 1 ../deps/ovs-version) +BUILD_TAG=$(../build-tag.sh) + # This is a bit complicated but we make sure that we only build OVS if # necessary, and at the moment --cache-from does not play nicely with multistage # builds: we need to push the intermediate image to the registry. Note that the @@ -101,20 +103,20 @@ OVS_VERSION=$(head -n 1 ../deps/ovs-version) if $PULL; then if [[ ${DOCKER_REGISTRY} == "" ]]; then - docker pull $PLATFORM_ARG ubuntu:20.04 + docker pull $PLATFORM_ARG ubuntu:22.04 else - docker pull ${DOCKER_REGISTRY}/antrea/ubuntu:20.04 - docker tag ${DOCKER_REGISTRY}/antrea/ubuntu:20.04 ubuntu:20.04 + docker pull ${DOCKER_REGISTRY}/antrea/ubuntu:22.04 + docker tag ${DOCKER_REGISTRY}/antrea/ubuntu:22.04 ubuntu:22.04 fi if [ "$DISTRO" == "ubuntu" ]; then IMAGES_LIST=( - "antrea/openvswitch-debs:$OVS_VERSION" - "antrea/openvswitch:$OVS_VERSION" + "antrea/openvswitch-debs:$BUILD_TAG" + "antrea/openvswitch:$BUILD_TAG" ) elif [ "$DISTRO" == "ubi" ]; then IMAGES_LIST=( - "antrea/openvswitch-rpms:$OVS_VERSION" - "antrea/openvswitch-ubi:$OVS_VERSION" + "antrea/openvswitch-rpms:$BUILD_TAG" + "antrea/openvswitch-ubi:$BUILD_TAG" ) fi for image in "${IMAGES_LIST[@]}"; do @@ -132,37 +134,37 @@ fi if [ "$DISTRO" == "ubuntu" ]; then docker build $PLATFORM_ARG --target ovs-debs \ - --cache-from antrea/openvswitch-debs:$OVS_VERSION \ - -t antrea/openvswitch-debs:$OVS_VERSION \ + --cache-from antrea/openvswitch-debs:$BUILD_TAG \ + -t antrea/openvswitch-debs:$BUILD_TAG \ --build-arg OVS_VERSION=$OVS_VERSION . docker build $PLATFORM_ARG \ - --cache-from antrea/openvswitch-debs:$OVS_VERSION \ - --cache-from antrea/openvswitch:$OVS_VERSION \ - -t antrea/openvswitch:$OVS_VERSION \ + --cache-from antrea/openvswitch-debs:$BUILD_TAG \ + --cache-from antrea/openvswitch:$BUILD_TAG \ + -t antrea/openvswitch:$BUILD_TAG \ --build-arg OVS_VERSION=$OVS_VERSION . elif [ "$DISTRO" == "ubi" ]; then docker build $PLATFORM_ARG --target ovs-rpms \ - --cache-from antrea/openvswitch-rpms:$OVS_VERSION \ - -t antrea/openvswitch-rpms:$OVS_VERSION \ + --cache-from antrea/openvswitch-rpms:$BUILD_TAG \ + -t antrea/openvswitch-rpms:$BUILD_TAG \ --build-arg OVS_VERSION=$OVS_VERSION \ -f Dockerfile.ubi . docker build \ - --cache-from antrea/openvswitch-rpms:$OVS_VERSION \ - --cache-from antrea/openvswitch-ubi:$OVS_VERSION \ - -t antrea/openvswitch-ubi:$OVS_VERSION \ + --cache-from antrea/openvswitch-rpms:$BUILD_TAG \ + --cache-from antrea/openvswitch-ubi:$BUILD_TAG \ + -t antrea/openvswitch-ubi:$BUILD_TAG \ --build-arg OVS_VERSION=$OVS_VERSION \ -f Dockerfile.ubi . fi if $PUSH; then if [ "$DISTRO" == "ubuntu" ]; then - docker push antrea/openvswitch-debs:$OVS_VERSION - docker push antrea/openvswitch:$OVS_VERSION + docker push antrea/openvswitch-debs:$BUILD_TAG + docker push antrea/openvswitch:$BUILD_TAG elif [ "$DISTRO" == "ubi" ]; then - docker push antrea/openvswitch-rpms:$OVS_VERSION - docker push antrea/openvswitch-ubi:$OVS_VERSION + docker push antrea/openvswitch-rpms:$BUILD_TAG + docker push antrea/openvswitch-ubi:$BUILD_TAG fi fi diff --git a/build/images/test/Dockerfile b/build/images/test/Dockerfile index 2d6fbdcd5a0..a526968dd8c 100644 --- a/build/images/test/Dockerfile +++ b/build/images/test/Dockerfile @@ -1,5 +1,19 @@ -ARG OVS_VERSION -FROM antrea/openvswitch:${OVS_VERSION} +# Copyright 2022 Antrea Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG BUILD_TAG +FROM antrea/openvswitch:${BUILD_TAG} LABEL maintainer="Antrea " LABEL description="A Docker image for Antrea integration tests." diff --git a/hack/build-antrea-linux-all.sh b/hack/build-antrea-linux-all.sh index bd931040d56..9cf787bc1be 100755 --- a/hack/build-antrea-linux-all.sh +++ b/hack/build-antrea-linux-all.sh @@ -21,9 +21,9 @@ function echoerr { } _usage="Usage: $0 [--pull] [--push-base-images] [--coverage] [--platform ] [--distro [ubuntu|ubi]] -Build the antrea/antrea-ubuntu image, as well as all the base images in the build chain. This is -typically used in CI to build the image with the latest version of all dependencies, taking into -account changes to all Dockerfiles. +Build the antrea image, as well as all the base images in the build chain. This is typically used in +CI to build the image with the latest version of all dependencies, taking into account changes to +all Dockerfiles. --pull Always attempt to pull a newer version of the base images. --push-base-images Push built images to the registry. Only base images will be pushed. --coverage Build the image with support for code coverage. @@ -101,10 +101,12 @@ if [ "$DISTRO" == "ubi" ]; then ARGS="$ARGS --distro ubi" fi -OVS_VERSION=$(head -n 1 build/images/deps/ovs-version) CNI_BINARIES_VERSION=$(head -n 1 build/images/deps/cni-binaries-version) GO_VERSION=$(head -n 1 build/images/deps/go-version) +BUILD_TAG=$(build/images/build-tag.sh) +echo "BUILD_TAG: $BUILD_TAG" + # We pull all images ahead of time, instead of calling the independent build.sh # scripts with "--pull". We do not want to overwrite the antrea/openvswitch # image we just built when calling build.sh to build the antrea/base-ubuntu @@ -112,27 +114,27 @@ GO_VERSION=$(head -n 1 build/images/deps/go-version) # new base images in the build chain. if $PULL; then if [[ ${DOCKER_REGISTRY} == "" ]]; then - docker pull $PLATFORM_ARG ubuntu:20.04 + docker pull $PLATFORM_ARG ubuntu:22.04 docker pull $PLATFORM_ARG golang:$GO_VERSION else - docker pull ${DOCKER_REGISTRY}/antrea/ubuntu:20.04 - docker tag ${DOCKER_REGISTRY}/antrea/ubuntu:20.04 ubuntu:20.04 + docker pull ${DOCKER_REGISTRY}/antrea/ubuntu:22.04 + docker tag ${DOCKER_REGISTRY}/antrea/ubuntu:22.04 ubuntu:22.04 docker pull ${DOCKER_REGISTRY}/antrea/golang:$GO_VERSION docker tag ${DOCKER_REGISTRY}/antrea/golang:$GO_VERSION golang:$GO_VERSION fi if [ "$DISTRO" == "ubuntu" ]; then IMAGES_LIST=( - "antrea/openvswitch-debs:$OVS_VERSION" - "antrea/openvswitch:$OVS_VERSION" + "antrea/openvswitch-debs:$BUILD_TAG" + "antrea/openvswitch:$BUILD_TAG" "antrea/cni-binaries:$CNI_BINARIES_VERSION" - "antrea/base-ubuntu:$OVS_VERSION" + "antrea/base-ubuntu:$BUILD_TAG" ) elif [ "$DISTRO" == "ubi" ]; then IMAGES_LIST=( - "antrea/openvswitch-rpms:$OVS_VERSION" - "antrea/openvswitch-ubi:$OVS_VERSION" + "antrea/openvswitch-rpms:$BUILD_TAG" + "antrea/openvswitch-ubi:$BUILD_TAG" "antrea/cni-binaries:$CNI_BINARIES_VERSION" - "antrea/base-ubi:$OVS_VERSION" + "antrea/base-ubi:$BUILD_TAG" ) fi for image in "${IMAGES_LIST[@]}"; do