-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure Github workflows use up-to-date base Docker images (#1951)
Relying on a CRON job to update the Antrea base images has proven sub-optimal: we sometimes push base images manually which do not match the checked-in Dockerfiles and CI tests run for PRs which update the Dockerfiles ignore these updates (making the tests worthless). We now ensure that Github workflows always build the base images before building the Antrea image, thanks to a new helper script. By relying on Docker caching (using the Dockerhub registry as the cache), we ensure that build times are not increased: in the absence of any change, we only add a handful of seconds to the build time. For now, we only update CI jobs run as Github workflow. Once this is merged, we should consider doing the same for Jenkins scripts. We could add support for DOCKER_REGISTRY to the new helper script (hack/build-antrea-ubuntu-all.sh). One question that we could ask now is whether these base images are even necessary: if caching works well, using one large Dockerfile should be just as fast, while simplifying build architecture. This is something we may want to revisit in the future. Maybe using base images only makes sense if we are going to share them across multiple images. See #1540
- Loading branch information
1 parent
2c1666d
commit cdbd4fc
Showing
9 changed files
with
149 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2021 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. | ||
|
||
set -eo pipefail | ||
|
||
# Change this when updating the OVS version! | ||
: "${OVS_VERSION:=2.14.0}" | ||
export OVS_VERSION | ||
|
||
function echoerr { | ||
>&2 echo "$@" | ||
} | ||
|
||
_usage="Usage: $0 [--pull] [--push-base-images] [--coverage] [--platform <PLATFORM>] | ||
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. | ||
--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. | ||
--platform <PLATFORM> Target platform for the images if server is multi-platform capable." | ||
|
||
function print_usage { | ||
echoerr "$_usage" | ||
} | ||
|
||
PULL=false | ||
PUSH=false | ||
COVERAGE=false | ||
PLATFORM="" | ||
|
||
while [[ $# -gt 0 ]] | ||
do | ||
key="$1" | ||
|
||
case $key in | ||
--pull) | ||
PULL=true | ||
shift | ||
;; | ||
--push-base-images) | ||
PUSH=true | ||
shift | ||
;; | ||
--coverage) | ||
COVERAGE=true | ||
shift | ||
;; | ||
--platform) | ||
PLATFORM="$2" | ||
shift 2 | ||
;; | ||
-h|--help) | ||
print_usage | ||
exit 0 | ||
;; | ||
*) # unknown option | ||
echoerr "Unknown option $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
pushd "$THIS_DIR/.." > /dev/null | ||
|
||
ARGS="" | ||
if $PUSH; then | ||
ARGS="$ARGS --push" | ||
fi | ||
if $PULL; then | ||
ARGS="$ARGS --pull" | ||
fi | ||
if [ "$PLATFORM" != "" ]; then | ||
ARGS="$ARGS --platform $PLATFORM" | ||
fi | ||
|
||
cd build/images/ovs | ||
./build.sh $ARGS | ||
cd - | ||
|
||
cd build/images/base | ||
./build.sh $ARGS | ||
cd - | ||
|
||
export NO_PULL=1 | ||
if $COVERAGE; then | ||
make build-ubuntu-coverage | ||
else | ||
make | ||
fi | ||
|
||
popd > /dev/null |