Skip to content

Commit

Permalink
ci: split ovn/ovs into base image
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Jun 4, 2021
1 parent 99ffe00 commit 2fe4fe1
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 76 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/build-kube-ovn-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Build Base
on: workflow_dispatch

jobs:
build-amd64:
name: Build AMD64
runs-on: ubuntu-20.04
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build
run: |
make base-amd64
make base-tar-amd64
- name: Upload image to artifact
uses: actions/upload-artifact@v2
with:
name: image-amd64
path: image-amd64.tar

build-arm64:
name: Build ARM64
runs-on: ubuntu-20.04
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:qemu-v5.2.0
platforms: arm64

- name: Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build
run: |
make base-arm64 || make base-arm64
make base-tar-arm64
- name: Upload image to artifact
uses: actions/upload-artifact@v2
with:
name: image-arm64
path: image-arm64.tar


push:
needs:
- build-arm64
- build-amd64
name: push
runs-on: ubuntu-20.04
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Download image
uses: actions/download-artifact@v2
with:
name: image-amd64

- name: Download image
uses: actions/download-artifact@v2
with:
name: image-arm64

- name: Load Image
run: |
docker load --input image-amd64.tar
docker load --input image-arm64.tar
- name: Push
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
COMMIT: ${{ github.sha }}
run: |
cat VERSION
TAG=$(cat VERSION)
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker images
docker push kubeovn/kube-ovn-base:$TAG-amd64
docker push kubeovn/kube-ovn-base:$TAG-arm64
docker manifest create kubeovn/kube-ovn-base:$TAG kubeovn/kube-ovn-base:$TAG-amd64 kubeovn/kube-ovn-base:$TAG-arm64
docker manifest push kubeovn/kube-ovn-base:$TAG
26 changes: 20 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ GOLDFLAGS = "-w -s -X github.com/kubeovn/kube-ovn/versions.COMMIT=$(COMMIT) -X g

# ARCH could be amd64,arm64
ARCH = amd64
# RPM_ARCH could be x86_64,aarch64
RPM_ARCH = x86_64

.PHONY: build-go
build-go:
Expand Down Expand Up @@ -42,15 +40,23 @@ build-dev-images: build-bin
build-dpdk:
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/amd64 -t $(REGISTRY)/kube-ovn-dpdk:19.11-$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile.dpdk1911 dist/images/

.PHONY: base-amd64
base-amd64:
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64 -o type=docker -f dist/images/Dockerfile.base dist/images/

.PHONY: base-arm64
base-arm64:
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/arm64 --build-arg ARCH=arm64 -t $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-arm64 -o type=docker -f dist/images/Dockerfile.base dist/images/

.PHONY: release
release: lint build-go
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/amd64 --build-arg ARCH=amd64 --build-arg RPM_ARCH=x86_64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/amd64 --build-arg ARCH=amd64 --build-arg RPM_ARCH=x86_64 -t $(REGISTRY)/vpc-nat-gateway:$(RELEASE_TAG) -o type=docker -f dist/images/vpcnatgateway/Dockerfile dist/images/vpcnatgateway
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/vpc-nat-gateway:$(RELEASE_TAG) -o type=docker -f dist/images/vpcnatgateway/Dockerfile dist/images/vpcnatgateway

.PHONY: release-arm
release-arm: build-go-arm
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/arm64 --build-arg ARCH=arm64 --build-arg RPM_ARCH=aarch64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/amd64 --build-arg ARCH=amd64 --build-arg RPM_ARCH=aarch64 -t $(REGISTRY)/vpc-nat-gateway:$(RELEASE_TAG) -o type=docker -f dist/images/vpcnatgateway/Dockerfile dist/images/vpcnatgateway
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/arm64 --build-arg ARCH=arm64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/arm64 --build-arg ARCH=arm64 -t $(REGISTRY)/vpc-nat-gateway:$(RELEASE_TAG) -o type=docker -f dist/images/vpcnatgateway/Dockerfile dist/images/vpcnatgateway

.PHONY: push-dev
push-dev:
Expand All @@ -64,6 +70,14 @@ push-release: release
tar:
docker save $(REGISTRY)/kube-ovn:$(RELEASE_TAG) > image.tar

.PHONY: base-tar-amd64
base-tar-amd64:
docker save $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64 > image-amd64.tar

.PHONY: base-tar-arm64
base-tar-arm64:
docker save $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-arm64 > image-arm64.tar

.PHONY: kind-init
kind-init:
kind delete cluster --name=kube-ovn
Expand Down
71 changes: 1 addition & 70 deletions dist/images/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,74 +1,5 @@
# syntax = docker/dockerfile:experimental
FROM ubuntu:20.04 as ovs-builder

ARG RPM_ARCH
ARG ARCH
ARG DEBIAN_FRONTEND=noninteractive
ENV SRC_DIR='/usr/src'

RUN apt update && apt install build-essential git libnuma-dev autoconf curl \
python3 libmnl-dev libpcap-dev libtool libcap-ng-dev libssl-dev pkg-config \
python3-six libunbound-dev libunwind-dev dh-make fakeroot debhelper dh-python \
flake8 python3-sphinx graphviz groff -y

RUN cd /usr/src/ && \
git clone -b branch-2.15 --depth=1 https://github.com/openvswitch/ovs.git && \
cd ovs && \
curl https://github.com/kubeovn/ovs/commit/df1c802f568be2af84aa81372fec46f5b09b4366.patch | git apply && \
curl https://github.com/kubeovn/ovs/commit/8dd4973bba021ce92eb9f42446d6c1c0e3474e25.patch | git apply && \

./boot.sh && \
rm -rf .git && \
DATAPATH_CONFIGURE_OPTS='--prefix=/usr --enable-shared' DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary

RUN cd /usr/src/ && git clone -b branch-20.12 --depth=1 https://github.com/ovn-org/ovn.git && \
cd ovn && \
curl https://github.com/kubeovn/ovn/commit/d8253981485e499979cc47c9453b6be8eebe5f0e.patch | git apply --exclude debian/changelog && \
curl https://github.com/kubeovn/ovn/commit/e19ff25f2464e67127c7eb1edef44803aa4a5462.patch | git apply && \
curl https://github.com/kubeovn/ovn/commit/289c62e3fcd05901dac4b727aa59f6cba058905f.patch | git apply && \
curl https://github.com/kubeovn/ovn/commit/e24734913d25c0bffdf1cfd79e14ef43d01e1019.patch | git apply && \
curl https://github.com/kubeovn/ovn/commit/afb8d70fd2488631fdd71af26c6fedf78ef9309a.patch | git apply && \
curl https://github.com/kubeovn/ovn/commit/402049e21ce5fb2d0ea23c04843f49a4ab65f027.patch | git apply && \
sed -i 's/OVN/ovn/g' debian/changelog && \
rm -rf .git && \
./boot.sh && \
DATAPATH_CONFIGURE_OPTS='--prefix=/usr --with-ovs-source=/usr/src/ovs' DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary

RUN mkdir /packages/ && \
cp /usr/src/libopenvswitch*.deb /packages && \
cp /usr/src/openvswitch-*.deb /packages && \
cp /usr/src/python3-openvswitch*.deb /packages && \
cp /usr/src/ovn-*.deb /packages && \
cd /packages && rm -f *dbg* *datapath* *docker* *vtep* *ipsec* *test* *dev*

FROM ubuntu:20.04
ARG RPM_ARCH

RUN apt update && apt install ca-certificates python3 hostname libunwind8 netbase \
ethtool iproute2 ncat libunbound-dev procps libatomic1 kmod \
tcpdump ipset curl uuid-runtime openssl inetutils-ping \
logrotate -y --no-install-recommends && \
rm -rf /var/lib/apt/lists/*

RUN mkdir -p /var/run/openvswitch && \
mkdir -p /var/run/ovn && \
mkdir -p /etc/cni/net.d && \
mkdir -p /opt/cni/bin

ARG ARCH
ENV CNI_VERSION=v0.8.7
RUN curl -sSf -L --retry 5 https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz | tar -xz -C . ./loopback ./portmap

ENV KUBE_VERSION="v1.13.2"

RUN curl -L https://dl.k8s.io/${KUBE_VERSION}/kubernetes-client-linux-${ARCH}.tar.gz | tar -xz -C . && cp ./kubernetes/client/bin/kubectl /usr/bin/kubectl \
&& chmod +x /usr/bin/kubectl && rm -rf ./kubernetes

RUN --mount=type=bind,target=/packages,from=ovs-builder,source=/packages \
dpkg -i /packages/libopenvswitch*.deb && \
dpkg -i /packages/openvswitch-*.deb && \
dpkg -i /packages/python3-openvswitch*.deb &&\
dpkg -i --ignore-depends=openvswitch-switch,openvswitch-common /packages/ovn-*.deb
FROM kubeovn/kube-ovn-base:v1.8.0

COPY *.sh /kube-ovn/
COPY 01-kube-ovn.conflist /kube-ovn/01-kube-ovn.conflist
Expand Down
68 changes: 68 additions & 0 deletions dist/images/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# syntax = docker/dockerfile:experimental
FROM ubuntu:20.04 as ovs-builder

ARG ARCH
ARG DEBIAN_FRONTEND=noninteractive
ENV SRC_DIR='/usr/src'

RUN apt update && apt install build-essential git libnuma-dev autoconf curl \
python3 libmnl-dev libpcap-dev libtool libcap-ng-dev libssl-dev pkg-config \
python3-six libunbound-dev libunwind-dev dh-make fakeroot debhelper dh-python \
flake8 python3-sphinx graphviz groff -y

RUN cd /usr/src/ && \
git clone -b branch-2.15 --depth=1 https://github.com/openvswitch/ovs.git && \
cd ovs && \
curl https://github.com/kubeovn/ovs/commit/df1c802f568be2af84aa81372fec46f5b09b4366.patch | git apply && \
curl https://github.com/kubeovn/ovs/commit/8dd4973bba021ce92eb9f42446d6c1c0e3474e25.patch | git apply && \
./boot.sh && \
rm -rf .git && \
DATAPATH_CONFIGURE_OPTS='--prefix=/usr --enable-shared' DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary

RUN cd /usr/src/ && git clone -b branch-20.12 --depth=1 https://github.com/ovn-org/ovn.git && \
cd ovn && \
curl https://github.com/kubeovn/ovn/commit/d8253981485e499979cc47c9453b6be8eebe5f0e.patch | git apply --exclude debian/changelog && \
curl https://github.com/kubeovn/ovn/commit/e19ff25f2464e67127c7eb1edef44803aa4a5462.patch | git apply && \
curl https://github.com/kubeovn/ovn/commit/289c62e3fcd05901dac4b727aa59f6cba058905f.patch | git apply && \
curl https://github.com/kubeovn/ovn/commit/e24734913d25c0bffdf1cfd79e14ef43d01e1019.patch | git apply && \
curl https://github.com/kubeovn/ovn/commit/afb8d70fd2488631fdd71af26c6fedf78ef9309a.patch | git apply && \
curl https://github.com/kubeovn/ovn/commit/402049e21ce5fb2d0ea23c04843f49a4ab65f027.patch | git apply && \
sed -i 's/OVN/ovn/g' debian/changelog && \
rm -rf .git && \
./boot.sh && \
DATAPATH_CONFIGURE_OPTS='--prefix=/usr --with-ovs-source=/usr/src/ovs' DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary

RUN mkdir /packages/ && \
cp /usr/src/libopenvswitch*.deb /packages && \
cp /usr/src/openvswitch-*.deb /packages && \
cp /usr/src/python3-openvswitch*.deb /packages && \
cp /usr/src/ovn-*.deb /packages && \
cd /packages && rm -f *dbg* *datapath* *docker* *vtep* *ipsec* *test* *dev*

FROM ubuntu:20.04

RUN apt update && apt install ca-certificates python3 hostname libunwind8 netbase \
ethtool iproute2 ncat libunbound-dev procps libatomic1 kmod \
tcpdump ipset curl uuid-runtime openssl inetutils-ping \
logrotate -y --no-install-recommends && \
rm -rf /var/lib/apt/lists/*

RUN mkdir -p /var/run/openvswitch && \
mkdir -p /var/run/ovn && \
mkdir -p /etc/cni/net.d && \
mkdir -p /opt/cni/bin

ARG ARCH
ENV CNI_VERSION=v0.8.7
RUN curl -sSf -L --retry 5 https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz | tar -xz -C . ./loopback ./portmap

ENV KUBE_VERSION="v1.21.1"

RUN curl -L https://dl.k8s.io/${KUBE_VERSION}/kubernetes-client-linux-${ARCH}.tar.gz | tar -xz -C . && cp ./kubernetes/client/bin/kubectl /usr/bin/kubectl \
&& chmod +x /usr/bin/kubectl && rm -rf ./kubernetes

RUN --mount=type=bind,target=/packages,from=ovs-builder,source=/packages \
dpkg -i /packages/libopenvswitch*.deb && \
dpkg -i /packages/openvswitch-*.deb && \
dpkg -i /packages/python3-openvswitch*.deb &&\
dpkg -i --ignore-depends=openvswitch-switch,openvswitch-common /packages/ovn-*.deb

0 comments on commit 2fe4fe1

Please sign in to comment.