Skip to content

Commit

Permalink
Remove Windows base image
Browse files Browse the repository at this point in the history
Signed-off-by: Wenying Dong <wenyingd@vmware.com>
  • Loading branch information
wenyingd committed May 15, 2024
1 parent d5b0093 commit 0171270
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
WINDOWS_PUSH=1; make build-windows
WINDOWS_PUSH=1 make build-windows
shell: bash

build-antrea-mc-controller:
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,7 @@ build-controller-ubi:
.PHONY: build-windows
build-windows:
@echo "===> Building Antrea bins and antrea/antrea-windows Docker image <==="
ifneq ($(WINDOWS_PUSH),)
$(CURDIR)/build/images/build-windows.sh --target agent --agent-tag $(DOCKER_IMG_VERSION) --push
else
$(CURDIR)/build/images/build-windows.sh --target agent --agent-tag $(DOCKER_IMG_VERSION)
endif
$(CURDIR)/build/images/build-windows.sh --agent-tag $(DOCKER_IMG_VERSION)

.PHONY: build-ubuntu-coverage
build-ubuntu-coverage: build-controller-ubuntu-coverage build-agent-ubuntu-coverage
Expand Down
22 changes: 0 additions & 22 deletions build/images/base-windows/Dockerfile

This file was deleted.

33 changes: 0 additions & 33 deletions build/images/base-windows/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion build/images/build-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function switch_windows_buildx() {
return
fi
trap 'docker buildx use --default ${original_buildx_instance}' EXIT
docker buildx ls | grep -q "${windows_buildx_name}"
docker buildx ls | grep "${windows_buildx_name}"
if [ $? -eq 0 ] ; then
docker buildx use --builder windows/amd64 "${windows_buildx_name}"
else
Expand Down
70 changes: 17 additions & 53 deletions build/images/build-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

source $THIS_DIR/build-utils.sh

_usage="Usage: $0 [--push] [--no-cache] [--target base|agent] [--agent-tag]
_usage="Usage: $0 [--push] [--agent-tag]
Build the antrea base image.
--push Push the built image to the registry
--no-cache Do not use the local build cache nor the cached image from the registry
--target Target container image to build.
--agent-tag Antrea Agent image tag. It is set only when target is agent"
--agent-tag Antrea Agent image tag"

PUSH=false
NO_CACHE=false
TARGET="base"
AGENT_TAG=""

while [[ $# -gt 0 ]]
Expand All @@ -44,14 +40,6 @@ case $key in
PUSH=true
shift
;;
--no-cache)
NO_CACHE=true
shift
;;
--target)
TARGET="$2"
shift 2
;;
--agent-tag)
AGENT_TAG="$2"
shift 2
Expand All @@ -67,19 +55,6 @@ case $key in
esac
done

if [ "$TARGET" != "base" ] && [ "$TARGET" != "agent" ]; then
echoerr "Invalid Windows target $TARGET"
exit 1
fi

if [ "$TARGET" = "agent" ] && [ "${AGENT_TAG}" = "" ]; then
echo "agent image version is not set, use 'latest'"
AGENT_TAG="latest"
elif [ "$TARGET" = "base" ] && [ "${AGENT_TAG}" != "" ]; then
echo "agent-tag works target is agent, version ${AGENT_TAG} is ignored"
AGENT_TAG=""
fi

if [ "$PUSH" = "false" ] && [ -n "${WINDOWS_PUSH}" ]; then
PUSH=true
fi
Expand All @@ -89,35 +64,24 @@ pushd $THIS_DIR > /dev/null
BUILD_ARGS=""
docker_file=""
BUILD_TAG=$(./build-tag.sh)
CNI_BINARIES_VERSION=$(head -n 1 deps/cni-binaries-version)
GO_VERSION=$(head -n 1 deps/go-version)

repository="antrea"

if [ "$TARGET" = "base" ]; then
CNI_BINARIES_VERSION=$(head -n 1 deps/cni-binaries-version)
BUILD_ARGS="--build-arg CNI_BINARIES_VERSION=${CNI_BINARIES_VERSION}"
image_name="base-windows"
image="${repository}/${image_name}"
popd > /dev/null
pushd base-windows
docker_file="Dockerfile"
cache_args=$(get_cache_args $image $BUILD_TAG $PUSH $NO_CACHE)
elif [ "$TARGET" = "agent" ]; then
GO_VERSION=$(head -n 1 deps/go-version)
BUILD_ARGS="--build-arg GO_VERSION=${GO_VERSION} --build-arg BUILD_TAG=${BUILD_TAG}"
image_name="antrea-windows"
image="${repository}/${image_name}"
popd > /dev/null
ANTREA_DIR=${THIS_DIR}/../../
pushd $ANTREA_DIR > /dev/null
docker_file="build/images/Dockerfile.build.windows"
cache_args=$(get_cache_args $image $AGENT_TAG $PUSH $NO_CACHE)
if $PUSH ; then
BUILD_TAG="${AGENT_TAG}"
else
BUILD_TAG="latest"
fi
image_name="antrea-windows"
image="${repository}/${image_name}"
BUILD_ARGS="--build-arg GO_VERSION=${GO_VERSION} --build-arg BUILD_TAG=${BUILD_TAG} --build-arg CNI_BINARIES_VERSION=${CNI_BINARIES_VERSION}"
if $PUSH ; then
BUILD_TAG="${AGENT_TAG}"
else
# Use latest as the image tag when trying to build the image and saved locally. It is used by CI.
BUILD_TAG="latest"
fi

docker_build_and_push_windows "${image}" "${docker_file}" "${cache_args}" "${BUILD_ARGS}" "${BUILD_TAG}" $PUSH
ANTREA_DIR=${THIS_DIR}/../../
pushd $ANTREA_DIR > /dev/null
docker_file="build/images/Dockerfile.build.windows"
docker_build_and_push_windows "${image}" "${docker_file}" "" "${BUILD_ARGS}" "${BUILD_TAG}" $PUSH
popd > /dev/null

popd > /dev/null
1 change: 1 addition & 0 deletions ci/jenkins/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ function deliver_antrea_windows_containerd {
echo "===== Build Antrea Windows ====="
rm -f antrea-windows.tar.gz
make build-windows
tar -czf antrea-windows.tar.gz antrea-windows.tar --remove-files

echo "===== Deliver Antrea Windows to Windows worker nodes and pull necessary images on Windows worker nodes ====="
sed -i 's/if (!(Test-Path $AntreaAgentConfigPath))/if ($true)/' hack/windows/Helper.psm1
Expand Down
19 changes: 2 additions & 17 deletions hack/build-antrea-windows-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ function echoerr {
>&2 echo "$@"
}

_usage="Usage: $0 [--pull] [--push-base-images] [--no-cache]
_usage="Usage: $0 [--push-base-images] [--no-cache]
Build the antrea/antrea-windows 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.
--push-base-images Push built images to the registry. Only Windows OVS image will be pushed.
--no-cache Do not use the local build cache nor the cached image from the registry.
This script is run on a Linux machine."
Expand All @@ -37,7 +36,6 @@ function print_usage {
echoerr "$_usage"
}

PULL=false
PUSH=false
NO_CACHE=false

Expand All @@ -46,10 +44,6 @@ do
key="$1"

case $key in
--pull)
PULL=true
shift
;;
--push-base-images)
PUSH=true
shift
Expand Down Expand Up @@ -81,19 +75,10 @@ if $NO_CACHE; then
ARGS="$ARGS --no-cache"
fi

if $PULL; then
docker pull ubuntu:22.04 || true
docker pull golang:$GO_VERSION || true
fi

cd build/images/ovs
./build.sh --distro windows $ARGS
cd -

cd build/images
./build-windows.sh --target base $ARGS
cd -

make build-windows

popd > /dev/null

0 comments on commit 0171270

Please sign in to comment.