Build steps for docker plugin added

This commit is contained in:
Raj Chaudhuri committed 2023-07-28 13:48:32 +05:30
1 parent 668bbcf4ed
commit c085ebed05
8 files changed
+150 -76

No files matched your search

+10 -3
View File
@@ -104,10 +104,17 @@ This makefile controls the build and scan processes. It provides the following p
and the following targets:
|Target|Description|
|build|Builds images matching the architecture of the local Docker engine, and loads it into the local Docker engine.|
|---|---|
|build-images|Builds images matching the architecture of the local Docker engine, and loads it into the local Docker engine.|
|publish-images|Builds multi-architecture images for all configured architectures, and pushes them to the registry.|
|clean-images|Removes images from the local docker engine.|
|build-plugin|Builds the [weave Docker Network Plugin(v2)](https://www.weave.works/docs/net/latest/install/plugin/plugin-v2/) on the local Docker engine. Requires published images.|
|publish-plugin|Pushes the plugin to the registry.|
|clean-plugin|Removes the plugin from the local Docker engine.|
|publish|Combines the publish-images and publish-plugin steps, in that order.|
|clean|Combines the clean-images and clean-plugin steps, in that order.|
|scan|Scans the weave-kube and weave-npc images using the configured scanner (currently grype), and stores the results in `reweave/scans`.|
|publish|Builds multi-architecture images for all configured architectures, and pushes them to the registry.|
|clean|Deletes images from the local Docker engine, and deletes scan results.|
|clean-scan|Deletes scan results.|
### reweave/tools/build-images.sh
+25 -2
View File
@@ -2,12 +2,35 @@
All changes made to the weave net codebase during the reweave effort will be documented in this file.
## 2.8.2-beta9
### Changed
* Ran `go mod tidy` to remove unused references
* Included tools and build steps to build the docker plugin (v2)
## 2.8.2-beta8
### Changed
* Upgraded github.com/opencontainers/runc to v1.1.5
* Upgraded github.com/docker/docker to v23.0.3+incompatible
* Upgraded github.com/docker/distribution to v2.8.2-beta.1+incompatible
## 2.8.2-beta7
### Changed
* Alpine base image was changed to `alpine:3.18.2`
## 2.8.2-beta6
## Changed
### Changed
* Alpine base image was changed to `alpine:3.17.3`
## Fixed
### Fixed
* Corrections were made in `reweave/build/Dockerfile` to ensure it builds everywhere, specifically on M1 Macs too
* `ALPINE_BASEIMAGE` was added as a parameter to `reweave/Makefile`. Now all changeable parameters are in one place
+36 -14
View File
@@ -1,42 +1,64 @@
IMAGE_VERSION ?= 2.8.2-beta8
IMAGE_VERSION ?= 2.8.2-beta9
REGISTRY_USER ?= weaveworks
ALPINE_BASEIMAGE ?= alpine:3.18.2
# Targets
.PHONY: build
build: submodule
.PHONY: build-images
build-images: submodule
REGISTRY_USER=${REGISTRY_USER} IMAGE_VERSION=${IMAGE_VERSION} \
PLATFORMS="$$(docker version -f '{{ .Server.Arch }}')" \
ALPINE_BASEIMAGE=$(ALPINE_BASEIMAGE) \
POSTBUILD=--load \
tools/build-images.sh
.PHONY: scan
scan:
.PHONY: build-plugin
build-plugin: ../prog/net-plugin/launch.sh ../prog/net-plugin/config.json
REGISTRY_USER=${REGISTRY_USER} IMAGE_VERSION=${IMAGE_VERSION} \
tools/scan-images.sh
tools/build-plugin.sh
.PHONY: publish
publish: submodule
.PHONY: build
build: build-images build-plugin
.PHONY: publish-images
publish-images: submodule
REGISTRY_USER=${REGISTRY_USER} IMAGE_VERSION=${IMAGE_VERSION} \
ALPINE_BASEIMAGE=$(ALPINE_BASEIMAGE) \
POSTBUILD=--push tools/build-images.sh
PUBLISH=true \
tools/build-images.sh
.PHONY: publish-plugin
publish-plugin:
REGISTRY_USER=${REGISTRY_USER} IMAGE_VERSION=${IMAGE_VERSION} \
PUBLISH=true \
tools/build-plugin.sh
.PHONY: publish
publish: publish-images publish-plugin
.PHONY: clean-images
clean-images:
REGISTRY_USER=${REGISTRY_USER} IMAGE_VERSION=${IMAGE_VERSION} \
tools/clean-images.sh
.PHONY: clean-scan
clean-scan:
tools/clean-scans.sh
.PHONY: clean-plugin
clean-plugin:
REGISTRY_USER=${REGISTRY_USER} IMAGE_VERSION=${IMAGE_VERSION} \
tools/clean-plugin.sh
.PHONY: clean
clean: clean-scan clean-images
clean: clean-plugin clean-images
.PHONY: submodule
submodule: ../tools/.git
../tools/.git:
git submodule update --init
.PHONY: scan
scan:
REGISTRY_USER=${REGISTRY_USER} IMAGE_VERSION=${IMAGE_VERSION} \
tools/scan-images.sh
.PHONY: clean-scan
clean-scan:
tools/clean-scans.sh
+25 -8
View File
@@ -17,17 +17,33 @@ fi
: "${WEAVE_VERSION=git-$(git rev-parse --short=12 HEAD)}"
: "${GIT_REVISION=$(git rev-parse HEAD)}"
: "${PLATFORMS:=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/s390x}"
: "${POSTBUILD:=}"
: "${PUBLISH:=}"
if [ "$PUBLISH" = "true" ]; then
POSTBUILD="--push"
elif [ "$PUBLISH" = "false" ]; then
POSTBUILD=""
else
POSTBUILD="--load"
fi
# These are the names of the images
WEAVER_IMAGE=${REGISTRY_USER}/weave:${IMAGE_VERSION}
WEAVEEXEC_IMAGE=${REGISTRY_USER}/weaveexec:${IMAGE_VERSION}
WEAVEKUBE_IMAGE=${REGISTRY_USER}/weave-kube:${IMAGE_VERSION}
WEAVENPC_IMAGE=${REGISTRY_USER}/weave-npc:${IMAGE_VERSION}
WEAVEDB_IMAGE=${REGISTRY_USER}/weavedb:${IMAGE_VERSION}
NETWORKTESTER_IMAGE=${REGISTRY_USER}/network-tester:${IMAGE_VERSION}
WEAVER_IMAGE=${REGISTRY_USER}/weave
WEAVEEXEC_IMAGE=${REGISTRY_USER}/weaveexec
WEAVEKUBE_IMAGE=${REGISTRY_USER}/weave-kube
WEAVENPC_IMAGE=${REGISTRY_USER}/weave-npc
WEAVEDB_IMAGE=${REGISTRY_USER}/weavedb
NETWORKTESTER_IMAGE=${REGISTRY_USER}/network-tester
build_image() {
IMAGENAME=$2
IMAGETAG=${IMAGENAME}:${IMAGE_VERSION}
if [ "$PUBLISH" = "true" ]; then
PUBLISHTAGOPT="-t ${IMAGENAME}:latest"
else
PUBLISHTAGOPT=""
fi
# Get directory of script file
a="/$0"; a="${a%/*}"; a="${a:-.}"; a="${a##/}/"; BINDIR=$(cd "$a"; pwd)
@@ -43,7 +59,8 @@ build_image() {
--build-arg=revision=${GIT_REVISION} \
--build-arg=imageversion=${IMAGE_VERSION} \
-f reweave/build/Dockerfile \
-t "$2" \
-t "${IMAGETAG}" \
${PUBLISHTAGOPT} \
.
cd -
+38
View File
@@ -0,0 +1,38 @@
#! /bin/sh
set -e
# These variables are used to tag the images. Change as
# required.
: "${IMAGE_VERSION:=}"
: "${REGISTRY_USER:=}"
# This variable is used to flag plugin publishing
: "${PUBLISH:=}"
if [ -z "${IMAGE_VERSION}" ] || [ -z "${REGISTRY_USER}" ] ; then
>&2 echo "Please provide valid values for IMAGE_VERSION and REGISTRY_USER."
exit 1
fi
WEAVER_IMAGE=${REGISTRY_USER}/weave:${IMAGE_VERSION}
PLUGIN_IMAGE=${REGISTRY_USER}/net-plugin:${IMAGE_VERSION}
PLUGIN_BUILD_IMG="plugin-builder"
PLUGIN_PARENT_DIR="../prog/net-plugin"
PLUGIN_WORK_DIR="${PLUGIN_PARENT_DIR}/rootfs"
docker container rm -f ${PLUGIN_BUILD_IMG} 2>/dev/null
docker container create --name=${PLUGIN_BUILD_IMG} "${WEAVER_IMAGE}" true
rm -rf ${PLUGIN_WORK_DIR}
mkdir ${PLUGIN_WORK_DIR}
docker export ${PLUGIN_BUILD_IMG} | tar -x -C ${PLUGIN_WORK_DIR}
docker container rm -f ${PLUGIN_BUILD_IMG}
cp "${PLUGIN_PARENT_DIR}/launch.sh" "${PLUGIN_WORK_DIR}/home/weave/launch.sh"
set +e
docker plugin disable "${PLUGIN_IMAGE}" 2>/dev/null
docker plugin rm "${PLUGIN_IMAGE}" 2>/dev/null
set -e
docker plugin create "${PLUGIN_IMAGE}" "${PLUGIN_PARENT_DIR}"
if [ "${PUBLISH}" = "true" ]; then
docker plugin push "${PLUGIN_IMAGE}"
fi
+16
View File
@@ -0,0 +1,16 @@
#! /bin/sh
set -e
# These variables are used to tag the images. Change as
# required.
: "${IMAGE_VERSION:=}"
: "${REGISTRY_USER:=}"
if [ -z "${IMAGE_VERSION}" ] || [ -z "${REGISTRY_USER}" ] ; then
>&2 echo "Please provide valid values for IMAGE_VERSION and REGISTRY_USER."
exit 1
fi
PLUGIN_IMAGE=${REGISTRY_USER}/net-plugin:${IMAGE_VERSION}
docker plugin rm "${PLUGIN_IMAGE}" 2>/dev/null