diff mbox series

[ovs-dev,v2] docker: add testing on local docker localhost:5000

Message ID 20210408223437.1368544-1-aidan.shribman@gmail.com
State Deferred
Headers show
Series [ovs-dev,v2] docker: add testing on local docker localhost:5000 | expand

Commit Message

Aidan Shribman April 8, 2021, 10:34 p.m. UTC
Add a set of docker targets which ease the building and testing of
docker images both on local registry (localhost:5000) as well as on the
public default registry (docker.io).

Signed-off-by: Aidan Shribman <aidan.shribman@gmail.com>
---
 .gitignore                              |  1 +
 Documentation/intro/install/general.rst | 31 +++++++++----------
 Makefile.am                             |  1 +
 utilities/automake.mk                   |  2 +-
 utilities/docker/.gitignore             |  2 ++
 utilities/docker/Makefile               | 22 --------------
 utilities/docker/automake.mk            | 40 +++++++++++++++++++++++++
 utilities/docker/debian/Dockerfile      |  5 ++--
 8 files changed, 64 insertions(+), 40 deletions(-)
 create mode 100644 utilities/docker/.gitignore
 delete mode 100644 utilities/docker/Makefile
 create mode 100644 utilities/docker/automake.mk

Comments

Simon Horman Oct. 6, 2023, 10:52 a.m. UTC | #1
On Thu, Apr 08, 2021 at 10:34:38PM +0000, Aidan Shribman wrote:
> Add a set of docker targets which ease the building and testing of
> docker images both on local registry (localhost:5000) as well as on the
> public default registry (docker.io).
> 
> Signed-off-by: Aidan Shribman <aidan.shribman@gmail.com>

Hi Aidan,

This patch appears to have gone stale in patchwork, for one reason or
another. If it is still relevant then I think it needs to be revisited,
by being reposted after appropriate preparation.

As such I'm marking this patch as "Deferred" in patchwork.

No action is required unless there is a desire to revisit this patch.
diff mbox series

Patch

diff --git a/.gitignore b/.gitignore
index f1cdcf124..b46a0528a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -79,3 +79,4 @@  testsuite.tmp.orig
 /Documentation/_build
 /.venv
 /cxx-check
+*.mod
diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst
index c4300cd53..804b7af52 100644
--- a/Documentation/intro/install/general.rst
+++ b/Documentation/intro/install/general.rst
@@ -510,28 +510,29 @@  For ovs vswitchd, we need to load ovs kernel modules on host.
 
 Hence, OVS containers kernel version needs to be same as that of host kernel.
 
-Export following variables in .env  and place it under
-project root::
+If you want to change the default values for building an image then set these
+variables::
 
-    $ OVS_BRANCH=<BRANCH>
-    $ OVS_VERSION=<VERSION>
-    $ DISTRO=<LINUX_DISTRO>
-    $ KERNEL_VERSION=<LINUX_KERNEL_VERSION>
-    $ GITHUB_SRC=<GITHUB_URL>
-    $ DOCKER_REPO=<REPO_TO_PUSH_IMAGE>
+    $ export OVS_BRANCH=<BRANCH>
+    $ export OVS_VERSION=<VERSION>
+    $ export DISTRO=<LINUX_DISTRO>
+    $ export KERNEL_VERSION=<LINUX_KERNEL_VERSION>
+    $ export GITHUB_SRC=<GITHUB_URL>
+    $ export DOCKER_REPO=<REPO_TO_PUSH_IMAGE>
+    $ export DOCKER_TAG=<DOCKER_IMAGE_TAG>
 
-To build ovs modules::
+To setup for using a local registry (localhost:5000)::
 
-    $ cd utilities/docker
-    $ make build
+    $ make docker-registry
+    $ export DOCKER_REPO=localhost:5000/ovsvswitch/ovs
 
-Compiled Modules will be tagged with docker image
+To build ovs modules (tagged with docker image)::
 
-To Push ovs modules::
+    $ make docker-build
 
-    $ make push
+To push ovs modules to docker repo::
 
-OVS docker image will be pushed to specified docker repo.
+     $ make docker-push
 
 Start ovsdb-server using below command::
 
diff --git a/Makefile.am b/Makefile.am
index cb8076433..5dcec201d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -499,3 +499,4 @@  include datapath-windows/include/automake.mk
 include windows/automake.mk
 include selinux/automake.mk
 include build-aux/automake.mk
+include utilities/docker/automake.mk
diff --git a/utilities/automake.mk b/utilities/automake.mk
index e2e22c39a..4d2f20570 100644
--- a/utilities/automake.mk
+++ b/utilities/automake.mk
@@ -56,7 +56,7 @@  EXTRA_DIST += \
 	utilities/ovs-vlan-test.in \
 	utilities/ovs-vsctl-bashcomp.bash \
 	utilities/checkpatch.py \
-        utilities/docker/Makefile \
+        utilities/docker/automake.mk \
         utilities/docker/ovs-override.conf \
         utilities/docker/start-ovs \
         utilities/docker/create_ovs_db.sh \
diff --git a/utilities/docker/.gitignore b/utilities/docker/.gitignore
new file mode 100644
index 000000000..5d05c158b
--- /dev/null
+++ b/utilities/docker/.gitignore
@@ -0,0 +1,2 @@ 
+vswitch.ovsschema
+ovsdb-tool
diff --git a/utilities/docker/Makefile b/utilities/docker/Makefile
deleted file mode 100644
index d8b08a3c9..000000000
--- a/utilities/docker/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@ 
-#export OVS_BRANCH=branch-2.11
-#export OVS_VERSION=2.11
-#export KERNEL_VERSION=4.15.0-54-generic
-#export DISTRO=debian
-#export GITHUB_SRC=https://github.com/openvswitch/ovs.git
-#export DOCKER_REPO=openvswitch/ovs
-
-# Example:
-#   make build
-#   make push
-
-REPO = ${DOCKER_REPO}
-tag = ${OVS_VERSION}_${DISTRO}_${KERNEL_VERSION}
-
-build: ;docker build -t ${REPO}:${tag} --build-arg DISTRO=${DISTRO} \
---build-arg OVS_BRANCH=${OVS_BRANCH} \
---build-arg KERNEL_VERSION=${KERNEL_VERSION} \
---build-arg GITHUB_SRC=${GITHUB_SRC} -f ${DISTRO}/Dockerfile .
-
-.PHONY: build
-
-push: ;docker push ${REPO}:${tag}
diff --git a/utilities/docker/automake.mk b/utilities/docker/automake.mk
new file mode 100644
index 000000000..4d9385ac8
--- /dev/null
+++ b/utilities/docker/automake.mk
@@ -0,0 +1,40 @@ 
+DIR := utilities/docker
+
+OVS_BRANCH ?= branch-2.11
+OVS_VERSION ?= 2.11
+KERNEL_VERSION ?= 4.15.0-54-generic
+DISTRO ?= debian
+GITHUB_SRC ?= https://github.com/openvswitch/ovs.git
+DOCKER_REPO ?= openvswitch/ovs
+DOCKER_TAG ?= ${OVS_VERSION}_${DISTRO}_${KERNEL_VERSION}
+DOCKER_SERVER ?= localhost:5000
+
+.PHONY: docker-registry
+docker-registry:
+	docker rm --force registry 2>/dev/null || true
+	docker run -d -p 5000:5000 --restart=always --name registry registry:2
+	@echo
+	@echo "# For using local repo set:"
+	@echo "export DOCKER_REPO=localhost:5000/openvswitch/ovs"
+	@echo
+	@echo "# For returning to public repo set:"
+	@echo "export DOCKER_REPO=openvswitch/ovs"
+
+$(DIR)/vswitch.ovsschema: vswitchd/vswitch.ovsschema
+	cp $< $@
+
+$(DIR)/ovsdb-tool: ovsdb/ovsdb-tool
+	cp $< $@
+
+.PHONY: docker-build
+docker-build: $(DIR)/vswitch.ovsschema $(DIR)/ovsdb-tool
+	cd $(DIR) && docker build -t ${DOCKER_REPO}:${DOCKER_TAG} \
+		--build-arg DISTRO=${DISTRO} \
+		--build-arg OVS_BRANCH=${OVS_BRANCH} \
+		--build-arg KERNEL_VERSION=${KERNEL_VERSION} \
+		--build-arg GITHUB_SRC=${GITHUB_SRC} \
+		-f ${DISTRO}/Dockerfile .
+
+.PHONY: docker-push
+docker-push:
+	cd $(DIR) && docker push ${DOCKER_REPO}:${DOCKER_TAG}
diff --git a/utilities/docker/debian/Dockerfile b/utilities/docker/debian/Dockerfile
index ed4baa8f9..be8e79277 100644
--- a/utilities/docker/debian/Dockerfile
+++ b/utilities/docker/debian/Dockerfile
@@ -6,14 +6,15 @@  ARG KERNEL_VERSION
 ARG GITHUB_SRC
 ARG DISTRO
 
-copy $DISTRO/build-kernel-modules.sh /build-kernel-modules.sh
+COPY $DISTRO/build-kernel-modules.sh /build-kernel-modules.sh
 RUN /build-kernel-modules.sh $KERNEL_VERSION $OVS_BRANCH $GITHUB_SRC
 
+COPY vswitch.ovsschema /usr/share/openvswitch/vswitch.ovsschema
+COPY ovsdb-tool /bin/ovsdb-tool
 COPY create_ovs_db.sh /etc/openvswitch/create_ovs_db.sh
 RUN /etc/openvswitch/create_ovs_db.sh
 
 COPY ovs-override.conf /etc/depmod.d/openvswitch.conf
-
 COPY start-ovs /bin/start-ovs
 VOLUME ["/var/log/openvswitch", "/var/lib/openvswitch",\
  "/var/run/openvswitch", "/etc/openvswitch"]