Skip to content

Commit

Permalink
Fix and improve the docker image building process of Flow Aggregator
Browse files Browse the repository at this point in the history
Fix the error of Flow Aggregator image after PR antrea-io#2004 changed the base
image to scratch.
Change the image name target "flow-aggregator-ubuntu" to
"flow-aggregtor-image" in Makefile since ubuntu is not relevant.
Change the base image of Flow Aggregator code coverage image to
ubuntu:20.04.
  • Loading branch information
dreamtalen committed Mar 31, 2021
1 parent 08ea67c commit e19bf9c
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 30 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build flow-aggregator Docker image
run: make flow-aggregator-ubuntu
run: make flow-aggregator-image
- name: Check flow-aggregator Docker image
run: docker run projects.registry.vmware.com/antrea/flow-aggregator --version
- name: Push flow-aggregator Docker image to registry
if: ${{ github.repository == 'vmware-tanzu/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ jobs:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
VERSION: ${{ needs.get-version.outputs.version }}
run: |
make flow-aggregator-ubuntu
make flow-aggregator-image
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push antrea/flow-aggregator:"${VERSION}"
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,13 @@ octant-antrea-ubuntu:
docker tag antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/octant-antrea-ubuntu
docker tag antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION)

.PHONY: flow-aggregator-ubuntu
flow-aggregator-ubuntu:
.PHONY: flow-aggregator-image
flow-aggregator-image:
@echo "===> Building antrea/flow-aggregator Docker image <==="
ifneq ($(NO_PULL),)
docker build -t antrea/flow-aggregator:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build -t antrea/flow-aggregator:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile .
else
docker build --pull -t antrea/flow-aggregator:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build --pull -t antrea/flow-aggregator:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile .
endif
docker tag antrea/flow-aggregator:$(DOCKER_IMG_VERSION) antrea/flow-aggregator
docker tag antrea/flow-aggregator:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/flow-aggregator
Expand All @@ -370,9 +370,9 @@ endif
flow-aggregator-ubuntu-coverage:
@echo "===> Building antrea/flow-aggregator-coverage Docker image <==="
ifneq ($(NO_PULL),)
docker build -t antrea/flow-aggregator-coverage:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile.coverage --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build -t antrea/flow-aggregator-coverage:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile.coverage .
else
docker build --pull -t antrea/flow-aggregator-coverage:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile.coverage --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build --pull -t antrea/flow-aggregator-coverage:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile.coverage .
endif
docker tag antrea/flow-aggregator-coverage:$(DOCKER_IMG_VERSION) antrea/flow-aggregator-coverage

Expand Down
10 changes: 6 additions & 4 deletions build/images/flow-aggregator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
ARG OVS_VERSION
FROM golang:1.15 as flow-aggregator-build

WORKDIR /antrea

COPY . /antrea

RUN make flow-aggregator
# Make sure the flow-aggregator binary is statically linked.
RUN CGO_ENABLED=0 make flow-aggregator

FROM scratch

LABEL maintainer="Antrea <[email protected]>"
LABEL description="The docker image for the flow aggregator"

USER root
ENV USER root

COPY --from=flow-aggregator-build /antrea/bin/flow-aggregator /usr/local/bin/
COPY --from=flow-aggregator-build /antrea/bin/flow-aggregator /

ENTRYPOINT ["/flow-aggregator"]
3 changes: 1 addition & 2 deletions build/images/flow-aggregator/Dockerfile.coverage
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ARG OVS_VERSION
FROM golang:1.15 as flow-aggregator-build

WORKDIR /antrea
Expand All @@ -7,7 +6,7 @@ COPY . /antrea

RUN make flow-aggregator flow-aggregator-instr-binary

FROM antrea/base-ubuntu:${OVS_VERSION}
FROM ubuntu:20.04

LABEL maintainer="Antrea <[email protected]>"
LABEL description="The docker image for the flow aggregator with code coverage measurement enabled for testing purposes."
Expand Down
8 changes: 1 addition & 7 deletions build/yamls/flow-aggregator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,8 @@ spec:
- args:
- --config
- /etc/flow-aggregator/flow-aggregator.conf
- --logtostderr=false
- --log_dir=/var/log/flowaggregator
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --logtostderr
- --v=0
command:
- flow-aggregator
image: projects.registry.vmware.com/antrea/flow-aggregator:latest
imagePullPolicy: IfNotPresent
name: flow-aggregator
Expand Down
8 changes: 1 addition & 7 deletions build/yamls/flow-aggregator/base/flow-aggregator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,8 @@ spec:
- args:
- --config
- /etc/flow-aggregator/flow-aggregator.conf
- --logtostderr=false
- --log_dir=/var/log/flowaggregator
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --logtostderr
- --v=0
command:
- flow-aggregator
name: flow-aggregator
image: flow-aggregator
ports:
Expand Down
2 changes: 1 addition & 1 deletion ci/jenkins/test-vmc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function deliver_antrea {
if [[ "$COVERAGE" == true ]]; then
VERSION="$CLUSTER" DOCKER_REGISTRY="${DOCKER_REGISTRY}" make flow-aggregator-ubuntu-coverage
else
VERSION="$CLUSTER" DOCKER_REGISTRY="${DOCKER_REGISTRY}" make flow-aggregator-ubuntu
VERSION="$CLUSTER" DOCKER_REGISTRY="${DOCKER_REGISTRY}" make flow-aggregator-image
fi
cd ci/jenkins

Expand Down
2 changes: 1 addition & 1 deletion ci/jenkins/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ function deliver_antrea {
docker tag "${DOCKER_REGISTRY}/antrea/sonobuoy-systemd-logs:v0.3" "sonobuoy/systemd-logs:v0.3"
fi
DOCKER_REGISTRY=${DOCKER_REGISTRY} make
DOCKER_REGISTRY=${DOCKER_REGISTRY} make flow-aggregator-ubuntu
DOCKER_REGISTRY=${DOCKER_REGISTRY} make flow-aggregator-image

echo "====== Delivering Antrea to all the Nodes ======"
echo "=== Fill serviceCIDRv6 and serviceCIDR ==="
Expand Down

0 comments on commit e19bf9c

Please sign in to comment.