Skip to content

Commit

Permalink
Use an Antrea base image instead of Ubuntu (#940)
Browse files Browse the repository at this point in the history
Fix #939.

Signed-off-by: Weiqiang Tang <weiqiangt@vmware.com>
  • Loading branch information
weiqiangt authored Jul 17, 2020
1 parent 4aadebb commit b5b762c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/update_ovs_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
docker pull antrea/openvswitch:$OVS_VERSION || true
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
./build_and_push.sh
cd ../base/
./build_and_push.sh
skip:
if: github.repository != 'vmware-tanzu/antrea'
runs-on: [ubuntu-18.04]
Expand Down
25 changes: 3 additions & 22 deletions build/images/Dockerfile.build.ubuntu
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
FROM ubuntu:18.04 as cni-binaries

RUN apt-get update && \
apt-get install -y --no-install-recommends wget ca-certificates

# Leading dot is required for the tar command below
ENV CNI_PLUGINS="./host-local ./loopback ./portmap"

RUN mkdir -p /opt/cni/bin && \
wget -q -O - https://github.com/containernetworking/plugins/releases/download/v0.8.6/cni-plugins-linux-amd64-v0.8.6.tgz | tar xz -C /opt/cni/bin $CNI_PLUGINS


FROM golang:1.13 as antrea-build

WORKDIR /antrea
Expand All @@ -23,19 +11,12 @@ COPY . /antrea
RUN make antrea-agent antrea-controller antrea-cni antctl-ubuntu


FROM antrea/openvswitch:2.13.0
FROM antrea/base-ubuntu:2.13.0

LABEL maintainer="Antrea <projectantrea-dev@googlegroups.com>"
LABEL description="A Docker image to deploy the Antrea CNI. Takes care of building the Antrea binaries as part of building the image."
LABEL description="The Docker image to deploy the Antrea CNI. "

USER root

RUN apt-get update && apt-get install -y --no-install-recommends \
ipset \
jq \
&& rm -rf /var/lib/apt/lists/*

COPY --from=cni-binaries /opt/cni/bin /opt/cni/bin

COPY --from=antrea-build /antrea/build/images/scripts/* /usr/local/bin/
COPY build/images/scripts/* /usr/local/bin/
COPY --from=antrea-build /antrea/bin/* /usr/local/bin/
23 changes: 2 additions & 21 deletions build/images/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
FROM ubuntu:18.04 as cni-binaries

RUN apt-get update && \
apt-get install -y --no-install-recommends wget ca-certificates

# Leading dot is required for the tar command below
ENV CNI_PLUGINS="./host-local ./loopback ./portmap"

RUN mkdir -p /opt/cni/bin && \
wget -q -O - https://github.com/containernetworking/plugins/releases/download/v0.8.6/cni-plugins-linux-amd64-v0.8.6.tgz | tar xz -C /opt/cni/bin $CNI_PLUGINS


FROM antrea/openvswitch:2.13.0
FROM antrea/base-ubuntu:2.13.0

LABEL maintainer="Antrea <projectantrea-dev@googlegroups.com>"
LABEL description="A Docker image to deploy the Antrea CNI. Requires the Antrea binaries to be built prior to building the image."
LABEL description="The Docker image to deploy the Antrea CNI. "

USER root

RUN apt-get update && apt-get install -y --no-install-recommends \
ipset \
jq \
&& rm -rf /var/lib/apt/lists/*

COPY --from=cni-binaries /opt/cni/bin /opt/cni/bin

COPY build/images/scripts/* /usr/local/bin/
COPY bin/* /usr/local/bin/
26 changes: 26 additions & 0 deletions build/images/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARG OVS_VERSION=2.13.0
FROM ubuntu:18.04 as cni-binaries

RUN apt-get update && \
apt-get install -y --no-install-recommends wget ca-certificates

# Leading dot is required for the tar command below
ENV CNI_PLUGINS="./host-local ./loopback ./portmap"

RUN mkdir -p /opt/cni/bin && \
wget -q -O - https://github.com/containernetworking/plugins/releases/download/v0.8.6/cni-plugins-linux-amd64-v0.8.6.tgz | tar xz -C /opt/cni/bin $CNI_PLUGINS


FROM antrea/openvswitch:${OVS_VERSION}

LABEL maintainer="Antrea <projectantrea-dev@googlegroups.com>"
LABEL description="Takes care of building the Antrea binaries as part of building the image."

USER root

RUN apt-get update && apt-get install -y --no-install-recommends \
ipset \
jq \
&& rm -rf /var/lib/apt/lists/*

COPY --from=cni-binaries /opt/cni/bin /opt/cni/bin
46 changes: 46 additions & 0 deletions build/images/base/build_and_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

# Copyright 2020 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.

# This is a very simple script that builds the base image for Antrea and pushes it to
# the Antrea Dockerhub (https://hub.docker.com/u/antrea). The image is tagged with the OVS version.

set -eo pipefail

function echoerr {
>&2 echo "$@"
}

if [ -z "$OVS_VERSION" ]; then
echoerr "The OVS_VERSION env variable must be set to a valid value (e.g. 2.13.0)"
exit 1
fi

THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

pushd $THIS_DIR > /dev/null

docker pull ubuntu:18.04

docker pull antrea/openvswitch:$OVS_VERSION

docker build \
-t antrea/base-ubuntu:$OVS_VERSION \
-f Dockerfile \
--build-arg OVS_VERSION=$OVS_VERSION .

docker push antrea/base-ubuntu:$OVS_VERSION

popd > /dev/null

0 comments on commit b5b762c

Please sign in to comment.