Skip to content

Commit

Permalink
address comments
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 22, 2024
1 parent a37690b commit 1cb6133
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 20 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,16 @@ jobs:
with:
show-progress: false
- name: Build Antrea Windows Docker image
run: make build-windows
if: ${{ github.repository != 'antrea-io/antrea' || github.event_name != 'push' || github.ref != 'refs/heads/main' }}
run: ./hack/build-antrea-windows-all.sh --pull
- name: Push Antrea Windows Docker image to registry
if: ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
make build-and-push-windows
./hack/build-antrea-windows-all.sh --pull --push-base-images --push-agent-image
shell: bash

build-antrea-mc-controller:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/build_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
docker push antrea/antrea-controller-ubi:"${VERSION}"
build-windows:
runs-on: [windows-2019]
runs-on: [ubuntu-latest]
needs: get-version
steps:
- uses: actions/checkout@v4
Expand All @@ -78,9 +78,8 @@ jobs:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
VERSION: ${{ needs.get-version.outputs.version }}
run: |
make build-windows
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push antrea/antrea-windows:"${VERSION}"
./hack/build-antrea-windows-all.sh --pull --push-agent-image
shell: bash

build-antrea-mc-controller:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker_update_base_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:

jobs:
build:
runs-on: windows-2019
runs-on: ubuntu-latest
steps:
- name: Check-out code
uses: actions/checkout@v4
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ UNAME_S := $(shell uname -s)
USERID := $(shell id -u)
GRPID := $(shell id -g)

WINDOWS_BUILD_OPTIONS :=
ifeq ($(NO_PULL),)
WINDOWS_BUILD_OPTIONS += --pull
endif
ifeq ($(RELEASE_STATUS),released)
WINDOWS_BUILD_OPTIONS += --agent-tag ${DOCKER_IMG_VERSION}
endif

.PHONY: install-hooks
install-hooks:
@echo "===> Copying Antrea git hooks to local <==="
Expand Down Expand Up @@ -373,12 +381,12 @@ build-controller-ubi:
.PHONY: build-windows
build-windows:
@echo "===> Building Antrea bins and antrea/antrea-windows Docker image <==="
$(CURDIR)/build/images/build-windows.sh --agent-tag "latest"
$(CURDIR)/build/images/build-windows.sh ${WINDOWS_BUILD_OPTIONS}

.PHONY: build-and-push-windows
build-and-push-windows:
@echo "===> Building Antrea bins and antrea/antrea-windows Docker image and pushing to registry <==="
$(CURDIR)/build/images/build-windows.sh --agent-tag $(DOCKER_IMG_VERSION) --push
$(CURDIR)/build/images/build-windows.sh --push ${WINDOWS_BUILD_OPTIONS}

.PHONY: build-ubuntu-coverage
build-ubuntu-coverage: build-controller-ubuntu-coverage build-agent-ubuntu-coverage
Expand Down
9 changes: 5 additions & 4 deletions build/images/Dockerfile.build.windows
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ ENV CNI_PLUGINS="./host-local.exe"
WORKDIR /antrea

ADD https://github.com/containernetworking/plugins/releases/download/${CNI_BINARIES_VERSION}/cni-plugins-windows-amd64-${CNI_BINARIES_VERSION}.tgz cni-plugins-windows-amd64.tgz
RUN mkdir -p /go/k/antrea/cni && \
tar -xzf cni-plugins-windows-amd64.tgz -C /go/k/antrea/cni ${CNI_PLUGINS} && \
rm cni-plugins-windows-amd64.tgz

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
Expand All @@ -34,12 +37,10 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build/ \
make windows-bin

RUN mkdir -p /go/k/antrea/bin && mkdir -p /go/k/antrea/cni && \
RUN mkdir -p /go/k/antrea/bin && \
cp /antrea/bin/antrea-agent.exe /go/k/antrea/bin/ && \
cp /antrea/bin/antctl.exe /go/k/antrea/bin/ && \
cp /antrea/build/images/scripts/Install-WindowsCNI.ps1 /go/k/antrea/ && \
cp /antrea/bin/antrea-cni.exe /go/k/antrea/cni/antrea.exe && \
tar -xzf cni-plugins-windows-amd64.tgz -C /go/k/antrea/cni ${CNI_PLUGINS}
cp /antrea/bin/antrea-cni.exe /go/k/antrea/cni/antrea.exe

FROM antrea/windows-ovs:${OVS_VERSION} as antrea-ovs

Expand Down
7 changes: 4 additions & 3 deletions build/images/ovs/Dockerfile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ ADD https://downloads.antrea.io/ovs/ovs-${OVS_VERSION}-antrea.0-win64.zip ovs-${
RUN unzip -q ovs-${OVS_VERSION}-antrea.0-win64.zip && mkdir -p openvswitch/redist
ADD https://aka.ms/vs/17/release/vc_redist.x64.exe /openvswitch/redist/redist.x64.exe
ADD https://indy.fulgan.com/SSL/openssl-1.0.2u-x64_86-win64.zip openssl-1.0.2u-x64_86-win64.zip
RUN mkdir openssl && unzip -q openssl-1.0.2u-x64_86-win64.zip -d openssl
RUN cp openssl/*.dll /openvswitch/usr/bin/ && \
cp openssl/*.dll /openvswitch/usr/sbin/
RUN mkdir openssl && unzip -q openssl-1.0.2u-x64_86-win64.zip -d openssl && \
cp openssl/*.dll /openvswitch/usr/bin/ && \
cp openssl/*.dll /openvswitch/usr/sbin/ && \
rm -rf openssl openssl-1.0.2u-x64_86-win64.zip

FROM mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0
COPY --from=antrea-windows-builder /openvswitch /openvswitch
30 changes: 25 additions & 5 deletions hack/build-antrea-windows-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,39 @@ function echoerr {
>&2 echo "$@"
}

_usage="Usage: $0 [--push-base-images] [--no-cache]
_usage="Usage: $0 [--pull] [--push-base-images] [--push-agent-image]
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 Windows OVS image will be pushed.
--push-agent-image Push built antrea/antrea-windows image to the registry.
This script is run on a Linux machine."

function print_usage {
echoerr "$_usage"
}

PUSH=false
PULL=false
PUSH_BASE=false
PUSH_AGENT=false

while [[ $# -gt 0 ]]
do
key="$1"

case $key in
--pull)
PULL=true
shift
;;
--push-base-images)
PUSH=true
PUSH_BASE=true
shift
;;
--push-agent-image)
PUSH_AGENT=true
shift
;;
-h|--help)
Expand All @@ -62,14 +74,22 @@ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
pushd "$THIS_DIR/.." > /dev/null

ARGS=""
if $PUSH; then
if $PULL; then
ARGS="$ARGS --pull"
fi

if $PUSH_BASE; then
ARGS="$ARGS --push"
fi

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

make build-windows
if $PUSH_AGENT; then
make build-and-push-windows
else
make build-windows
fi

popd > /dev/null

0 comments on commit 1cb6133

Please sign in to comment.