From 15743aeea353de600c1ff180c6f1d9e9b425b174 Mon Sep 17 00:00:00 2001 From: Nicolas Belouin Date: Thu, 12 Oct 2023 16:58:49 +0200 Subject: [PATCH] chore: Revamp build system to overcome Cross issues This commit completely refactor the build system for akri: - Rust components are now built within docker using XX for cross-compilation - Made samples clear in a separate Makefile to ease with them getting out of the main repo soon - Remove cross intermediate image - Use buildx to build for multiple architectures - Merge largely similar Dockerfiles - Upgrade opcua-monitoring-broker to .NET 6 - Upgrade opencv intermediate image to .NET 6 (the onvif broker still needs migration) Signed-off-by: Nicolas Belouin --- .dockerignore | 89 +-------- Makefile | 53 +++-- build/akri-containers.mk | 95 +-------- build/akri-dotnet-containers.mk | 51 +---- build/akri-python-containers.mk | 48 ----- build/akri-rust-containers.mk | 49 ----- build/containers/Dockerfile.agent | 33 ---- build/containers/Dockerfile.agent-full | 32 --- .../Dockerfile.anomaly-detection-app | 19 -- build/containers/Dockerfile.controller | 15 -- .../Dockerfile.debug-echo-discovery | 15 -- build/containers/Dockerfile.onvif-discovery | 15 -- build/containers/Dockerfile.opcua-discovery | 15 -- .../Dockerfile.opcua-monitoring-broker | 19 +- build/containers/Dockerfile.python-app | 23 +++ build/containers/Dockerfile.rust | 40 ++++ build/containers/Dockerfile.udev-discovery | 15 -- build/containers/Dockerfile.udev-video-broker | 20 -- .../containers/Dockerfile.video-streaming-app | 19 -- .../Dockerfile.webhook-configuration | 21 -- .../intermediate/Dockerfile.opencvsharp-build | 183 +++++++++--------- .../Dockerfile.rust-crossbuild-amd64 | 20 -- .../Dockerfile.rust-crossbuild-arm32v7 | 25 --- .../Dockerfile.rust-crossbuild-arm64v8 | 25 --- build/intermediate-containers.mk | 77 +------- build/samples.mk | 36 ++++ .../helm/templates/webhook-configuration.yaml | 4 +- samples/apps/anomaly-detection-app/README.md | 2 +- .../{anomaly_detection.py => app.py} | 0 samples/apps/video-streaming-app/README.md | 4 +- .../{streaming.py => app.py} | 0 .../opcua-monitoring-broker.csproj | 2 +- test/e2e/test_udev.py | 4 +- 33 files changed, 258 insertions(+), 810 deletions(-) delete mode 100644 build/akri-python-containers.mk delete mode 100644 build/akri-rust-containers.mk delete mode 100644 build/containers/Dockerfile.agent delete mode 100644 build/containers/Dockerfile.agent-full delete mode 100644 build/containers/Dockerfile.anomaly-detection-app delete mode 100644 build/containers/Dockerfile.controller delete mode 100644 build/containers/Dockerfile.debug-echo-discovery delete mode 100644 build/containers/Dockerfile.onvif-discovery delete mode 100644 build/containers/Dockerfile.opcua-discovery create mode 100644 build/containers/Dockerfile.python-app create mode 100644 build/containers/Dockerfile.rust delete mode 100644 build/containers/Dockerfile.udev-discovery delete mode 100644 build/containers/Dockerfile.udev-video-broker delete mode 100644 build/containers/Dockerfile.video-streaming-app delete mode 100644 build/containers/Dockerfile.webhook-configuration delete mode 100644 build/containers/intermediate/Dockerfile.rust-crossbuild-amd64 delete mode 100644 build/containers/intermediate/Dockerfile.rust-crossbuild-arm32v7 delete mode 100644 build/containers/intermediate/Dockerfile.rust-crossbuild-arm64v8 create mode 100644 build/samples.mk rename samples/apps/anomaly-detection-app/{anomaly_detection.py => app.py} (100%) rename samples/apps/video-streaming-app/{streaming.py => app.py} (100%) diff --git a/.dockerignore b/.dockerignore index 4a01fc05c..21936581d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,80 +1,11 @@ - -# Ignore everything ** - -# The anomaly detection app is built using a `docker build` command, -# so the source code needs to be available to the container -# build -!samples/apps/anomaly-detection-app - -# ONVIF broker is built using a `docker build` command, so -# the source code needs to be available to the DotNet container -# build -!samples/brokers/onvif-video-broker - -# OPC UA broker is built using a `docker build` command, so -# the source code needs to be available to the DotNet container -# build -!samples/brokers/opcua-monitoring-broker - -# The streaming app is built using a `docker build` command, so -# the source code needs to be available to the container -# build -!samples/apps/video-streaming-app - -# The Rust binaries are not built with a `docker build` -# command (they are built using Cargo Cross, which I think -# uses a docker run). Because of this, the Rust src and -# Cargo.toml files can be ignored by docker. - - -# Cross-build binaries need to be available -# It is not clear to me why !target/*/*/controller -# does not work here, but it doesn't seem to. So -# for now, explicitly specifying each cross-build -# target and configuration path. -!target/x86_64-unknown-linux-gnu/debug/controller -!target/x86_64-unknown-linux-gnu/release/controller -!target/x86_64-unknown-linux-gnu/debug/agent -!target/x86_64-unknown-linux-gnu/release/agent -!target/x86_64-unknown-linux-gnu/debug/agent-full -!target/x86_64-unknown-linux-gnu/release/agent-full -!target/x86_64-unknown-linux-gnu/debug/udev-video-broker -!target/x86_64-unknown-linux-gnu/release/udev-video-broker -!target/x86_64-unknown-linux-gnu/debug/webhook-configuration -!target/x86_64-unknown-linux-gnu/release/webhook-configuration -!target/x86_64-unknown-linux-gnu/release/udev-discovery-handler -!target/x86_64-unknown-linux-gnu/release/debug-echo-discovery-handler -!target/x86_64-unknown-linux-gnu/release/onvif-discovery-handler -!target/x86_64-unknown-linux-gnu/release/opcua-discovery-handler -!target/aarch64-unknown-linux-gnu/debug/controller -!target/aarch64-unknown-linux-gnu/release/controller -!target/aarch64-unknown-linux-gnu/debug/agent -!target/aarch64-unknown-linux-gnu/release/agent -!target/aarch64-unknown-linux-gnu/debug/agent-full -!target/aarch64-unknown-linux-gnu/release/agent-full -!target/aarch64-unknown-linux-gnu/debug/udev-video-broker -!target/aarch64-unknown-linux-gnu/release/udev-video-broker -!target/aarch64-unknown-linux-gnu/debug/webhook-configuration -!target/aarch64-unknown-linux-gnu/release/webhook-configuration -!target/aarch64-unknown-linux-gnu/release/udev-discovery-handler -!target/aarch64-unknown-linux-gnu/release/debug-echo-discovery-handler -!target/aarch64-unknown-linux-gnu/release/onvif-discovery-handler -!target/aarch64-unknown-linux-gnu/release/opcua-discovery-handler -!target/armv7-unknown-linux-gnueabihf/debug/controller -!target/armv7-unknown-linux-gnueabihf/release/controller -!target/armv7-unknown-linux-gnueabihf/debug/agent -!target/armv7-unknown-linux-gnueabihf/release/agent -!target/armv7-unknown-linux-gnueabihf/debug/agent-full -!target/armv7-unknown-linux-gnueabihf/release/agent-full -!target/armv7-unknown-linux-gnueabihf/debug/udev-video-broker -!target/armv7-unknown-linux-gnueabihf/release/udev-video-broker -!target/armv7-unknown-linux-gnueabihf/debug/webhook-configuration -!target/armv7-unknown-linux-gnueabihf/release/webhook-configuration -!target/armv7-unknown-linux-gnueabihf/release/udev-discovery-handler -!target/armv7-unknown-linux-gnueabihf/release/debug-echo-discovery-handler -!target/armv7-unknown-linux-gnueabihf/release/onvif-discovery-handler -!target/armv7-unknown-linux-gnueabihf/release/opcua-discovery-handler - -# Cross toml file needs to be available for making the cross build containers -!Cross.toml \ No newline at end of file +!Cargo.toml +!Cargo.lock +!agent +!controller +!discovery-handler-modules +!discovery-handlers +!discovery-utils +!samples +!shared +!webhooks \ No newline at end of file diff --git a/Makefile b/Makefile index 56ebc34d2..66f98260f 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,28 @@ -BUILD_AMD64 ?= 1 -BUILD_ARM32 ?= 1 -BUILD_ARM64 ?= 1 +BUILDX_ARGS = +EXTRA_CARGO_ARGS = + +PUSH ?= +LOAD ?= +LOCAL_ARCH = $(shell uname -m) +ifeq ($(LOAD), 1) +PLATFORMS ?= LOCAL_ARCH +$(intcmp 1,$(words $(PLATFORMS)), $(error Cannot load for more than one platform)) +else +PLATFORMS ?= amd64 arm64 arm/v7 +endif + +null := +space := $(null) # +comma := , + +DOCKER_PLATFORMS = $(subst $(space),$(comma),$(strip $(addprefix linux/, $(PLATFORMS)))) # Specify flag to build optimized release version of rust components. # Set to be empty to use debug builds. BUILD_RELEASE_FLAG ?= 1 -# Space separated list of rust packages to not build such as the following to not build -# the udev discovery handler library or module: "akri-udev udev-discovery-handler" -PACKAGES_TO_EXCLUDE ?= - -# Incremental compilation causes rustc to save additional information to disk which will be -# reused when recompiling the crate, improving re-compile times. -# The additional information is stored in the target directory. -# By default for cargo builds, it is enabled in debug mode and disabled in release mode. -CARGO_INCREMENTAL ?= 0 - -BUILD_SLIM_AGENT ?= 1 -FULL_AGENT_EXECUTABLE_NAME ?= agent-full # Specify which features of the Agent to build, namely which Discovery Handlers -# should be embedded if any. The "agent-full" feature must be enabled to use the embedded -# Discovery Handlers. IE: AGENT_FEATURES="agent-full onvif-feat opcua-feat udev-feat" +# should be embedded if any. IE: AGENT_FEATURES="onvif-feat opcua-feat udev-feat" AGENT_FEATURES ?= REGISTRY ?= devcaptest.azurecr.io @@ -47,12 +49,21 @@ AMD64_SUFFIX = amd64 ARM32V7_SUFFIX = arm32v7 ARM64V8_SUFFIX = arm64v8 -AMD64_TARGET = x86_64-unknown-linux-gnu -ARM32V7_TARGET = armv7-unknown-linux-gnueabihf -ARM64V8_TARGET = aarch64-unknown-linux-gnu - +COMMON_DOCKER_BUILD_ARGS = $(if $(LOAD), --load) $(if $(PUSH), --push) --platform=$(DOCKER_PLATFORMS) # Intermediate container defines include build/intermediate-containers.mk # Akri container defines include build/akri-containers.mk +include build/samples.mk + +.PHONY: all +all: akri samples opencv-base + +.PHONY: push +push: PUSH = 1 +push: all + +.PHONY: load +load: LOAD = 1 +load: all \ No newline at end of file diff --git a/build/akri-containers.mk b/build/akri-containers.mk index 93a751570..bd51ae79e 100644 --- a/build/akri-containers.mk +++ b/build/akri-containers.mk @@ -1,38 +1,3 @@ -USE_OPENCV_BASE_VERSION = 0.0.11 - -# Akri container defines -include build/akri-rust-containers.mk -include build/akri-dotnet-containers.mk -include build/akri-python-containers.mk - -# -# Functions for building Agent with or without Discovery Handlers -# -# Build the Agent without any Discovery Handlers embedded -define agent_build_slim - CARGO_INCREMENTAL=$(CARGO_INCREMENTAL) PKG_CONFIG_ALLOW_CROSS=1 cross build $(if $(BUILD_RELEASE_FLAG), --release) --target=$(1) --manifest-path agent/Cargo.toml -endef - -# Build the Agent with features that embed Discovery Handlers and rename the executable in case subsequently -# building a slim Agent -define agent_build_with_features - CARGO_INCREMENTAL=$(CARGO_INCREMENTAL) PKG_CONFIG_ALLOW_CROSS=1 cross build $(if $(BUILD_RELEASE_FLAG), --release) --target=$(1) --manifest-path agent/Cargo.toml \ - --features "${AGENT_FEATURES}" - mv target/$(1)/$(if $(BUILD_RELEASE_FLAG),release,debug)/agent target/$(1)/$(if $(BUILD_RELEASE_FLAG),release,debug)/${FULL_AGENT_EXECUTABLE_NAME} -endef - -# -# -# INSTALL-CROSS: install cargo cross building tool: -# -# `make install-cross` -# -# -.PHONY: install-cross -install-cross: - cargo install cross - - # # # AKRI: make and push the images for akri: @@ -46,58 +11,14 @@ install-cross: # To make a slim and full Agent, with full agent executable renamed agent-full: `AGENT_FEATURES="agent-full onvif-feat opcua-feat udev-feat" BUILD_SLIM_AGENT=1 make akri-agent` # .PHONY: akri -akri: akri-build akri-docker-all -akri-build: install-cross akri-cross-build -akri-docker-all: akri-docker-controller akri-docker-agent akri-docker-udev akri-docker-onvif akri-docker-streaming akri-docker-opcua-monitoring akri-docker-anomaly-detection akri-docker-webhook-configuration akri-docker-debug-echo-discovery akri-docker-onvif-discovery akri-docker-opcua-discovery akri-docker-udev-discovery +akri: akri-agent akri-agent-full akri-controller akri-webhook-configuration akri-debug-echo-discovery-handler akri-onvif-discovery-handler akri-opcua-discovery-handler akri-udev-discovery-handler -akri-cross-build: akri-cross-build-amd64 akri-cross-build-arm32 akri-cross-build-arm64 -akri-cross-build-amd64: -ifeq (1, $(BUILD_AMD64)) - CARGO_INCREMENTAL=$(CARGO_INCREMENTAL) PKG_CONFIG_ALLOW_CROSS=1 cross build $(if $(BUILD_RELEASE_FLAG), --release) --target=$(AMD64_TARGET) --workspace --exclude agent $(foreach package,$(wordlist 1, 100, $(PACKAGES_TO_EXCLUDE)),--exclude $(package)) -ifneq ($(AGENT_FEATURES),) - $(call agent_build_with_features,$(AMD64_TARGET)) -endif -ifeq (1, $(BUILD_SLIM_AGENT)) - $(call agent_build_slim,$(AMD64_TARGET)) -endif -endif -akri-cross-build-arm32: -ifeq (1, $(BUILD_ARM32)) - CARGO_INCREMENTAL=$(CARGO_INCREMENTAL) PKG_CONFIG_ALLOW_CROSS=1 cross build $(if $(BUILD_RELEASE_FLAG), --release) --target=$(ARM32V7_TARGET) --workspace --exclude agent $(foreach package,$(wordlist 1, 100, $(PACKAGES_TO_EXCLUDE)),--exclude $(package)) -ifneq ($(AGENT_FEATURES),) - $(call agent_build_with_features,$(ARM32V7_TARGET)) -endif -ifeq (1, $(BUILD_SLIM_AGENT)) - $(call agent_build_slim,$(ARM32V7_TARGET)) -endif -endif -akri-cross-build-arm64: -ifeq (1, ${BUILD_ARM64}) - CARGO_INCREMENTAL=$(CARGO_INCREMENTAL) PKG_CONFIG_ALLOW_CROSS=1 cross build $(if $(BUILD_RELEASE_FLAG), --release) --target=$(ARM64V8_TARGET) --workspace --exclude agent $(foreach package,$(wordlist 1, 100, $(PACKAGES_TO_EXCLUDE)),--exclude $(package)) -ifneq ($(AGENT_FEATURES),) - $(call agent_build_with_features,$(ARM64V8_TARGET)) -endif -ifeq (1, $(BUILD_SLIM_AGENT)) - $(call agent_build_slim,$(ARM64V8_TARGET)) -endif -endif +akri-%: + docker buildx build $(COMMON_DOCKER_BUILD_ARGS) --build-arg AKRI_COMPONENT=$* --tag "$(PREFIX)/$(subst -handler,,$*):$(LABEL_PREFIX)" --build-arg EXTRA_CARGO_ARGS="$(if $(BUILD_RELEASE_FLAG), --release)" --file $(DOCKERFILE_DIR)/Dockerfile.rust . -# Rust targets -$(eval $(call add_rust_targets,controller,controller)) -$(eval $(call add_rust_targets,agent,agent)) -$(eval $(call add_rust_targets,agent-full,agent-full)) -$(eval $(call add_rust_targets,udev,udev-video-broker)) -$(eval $(call add_rust_targets,webhook-configuration,webhook-configuration)) -$(eval $(call add_rust_targets,debug-echo-discovery,debug-echo-discovery)) -$(eval $(call add_rust_targets,onvif-discovery,onvif-discovery)) -$(eval $(call add_rust_targets,opcua-discovery,opcua-discovery)) -$(eval $(call add_rust_targets,udev-discovery,udev-discovery)) - -# .NET targets -$(eval $(call add_onvif_target,onvif,onvif-video-broker)) -$(eval $(call add_opcua_target,opcua-monitoring,opcua-monitoring-broker)) - -# Python targets -$(eval $(call add_python_target,anomaly-detection,anomaly-detection-app)) -$(eval $(call add_python_target,streaming,video-streaming-app)) +.PHONY: akri-agent-full +akri-agent-full: +ifneq (,$(strip $(AGENT_FEATURES))) + docker buildx build $(COMMON_DOCKER_BUILD_ARGS) --build-arg AKRI_COMPONENT=agent --build-arg EXTRA_CARGO_ARGS="$(if $(BUILD_RELEASE_FLAG), --release) -F agent-full,$(subst $(space),$(comma),$(AGENT_FEATURES))" --tag "$(PREFIX)/agent-full:$(LABEL_PREFIX)" --file $(DOCKERFILE_DIR).rust . +endif diff --git a/build/akri-dotnet-containers.mk b/build/akri-dotnet-containers.mk index 7cf8cf50c..3def3f1a5 100644 --- a/build/akri-dotnet-containers.mk +++ b/build/akri-dotnet-containers.mk @@ -44,53 +44,4 @@ define add_onvif_target $(1)-docker-multi-arch-push: $(ENABLE_DOCKER_MANIFEST) docker manifest push $(PREFIX)/$(2):$(LABEL_PREFIX) -endef - -define add_opcua_target - akri-$(1): akri-build akri-docker-$(1) - akri-docker-$(1): $(1)-build $(1)-docker-per-arch $(1)-docker-multi-arch-create $(1)-docker-multi-arch-push - $(1)-build: $(1)-build-amd64 $(1)-build-arm32 $(1)-build-arm64 - $(1)-docker-per-arch: $(1)-docker-per-arch-amd64 $(1)-docker-per-arch-arm32 $(1)-docker-per-arch-arm64 - - $(1)-build-amd64: - ifeq (1, ${BUILD_AMD64}) - docker build $(CACHE_OPTION) -f $(DOCKERFILE_DIR)/Dockerfile.$(2) . -t $(PREFIX)/$(2):$(LABEL_PREFIX)-$(AMD64_SUFFIX) --build-arg OUTPUT_PLATFORM_TAG=3.1-bullseye-slim --build-arg DOTNET_PUBLISH_RUNTIME=linux-x64 - endif - $(1)-build-arm32: - ifeq (1, ${BUILD_ARM32}) - docker build $(CACHE_OPTION) -f $(DOCKERFILE_DIR)/Dockerfile.$(2) . -t $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM32V7_SUFFIX) --build-arg OUTPUT_PLATFORM_TAG=3.1-bullseye-slim-$(ARM32V7_SUFFIX) --build-arg DOTNET_PUBLISH_RUNTIME=linux-arm - endif - $(1)-build-arm64: - ifeq (1, ${BUILD_ARM64}) - docker build $(CACHE_OPTION) -f $(DOCKERFILE_DIR)/Dockerfile.$(2) . -t $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM64V8_SUFFIX) --build-arg OUTPUT_PLATFORM_TAG=3.1-bullseye-slim-$(ARM64V8_SUFFIX) --build-arg DOTNET_PUBLISH_RUNTIME=linux-arm64 - endif - - $(1)-docker-per-arch-amd64: - ifeq (1, ${BUILD_AMD64}) - docker push $(PREFIX)/$(2):$(LABEL_PREFIX)-$(AMD64_SUFFIX) - endif - $(1)-docker-per-arch-arm32: - ifeq (1, ${BUILD_ARM32}) - docker push $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM32V7_SUFFIX) - endif - $(1)-docker-per-arch-arm64: - ifeq (1, ${BUILD_ARM64}) - docker push $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM64V8_SUFFIX) - endif - - $(1)-docker-multi-arch-create: - ifeq (1, ${BUILD_AMD64}) - $(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/$(2):$(LABEL_PREFIX) $(PREFIX)/$(2):$(LABEL_PREFIX)-$(AMD64_SUFFIX) - endif - ifeq (1, ${BUILD_ARM32}) - $(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/$(2):$(LABEL_PREFIX) $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM32V7_SUFFIX) - endif - ifeq (1, ${BUILD_ARM64}) - $(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/$(2):$(LABEL_PREFIX) $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM64V8_SUFFIX) - endif - - $(1)-docker-multi-arch-push: - $(ENABLE_DOCKER_MANIFEST) docker manifest push $(PREFIX)/$(2):$(LABEL_PREFIX) - -endef - +endef \ No newline at end of file diff --git a/build/akri-python-containers.mk b/build/akri-python-containers.mk deleted file mode 100644 index 17d75d1e9..000000000 --- a/build/akri-python-containers.mk +++ /dev/null @@ -1,48 +0,0 @@ - -define add_python_target - akri-$(1): akri-build akri-docker-$(1) - akri-docker-$(1): $(1)-build $(1)-docker-per-arch $(1)-docker-multi-arch-create $(1)-docker-multi-arch-push - $(1)-build: $(1)-build-amd64 $(1)-build-arm32 $(1)-build-arm64 - $(1)-docker-per-arch: $(1)-docker-per-arch-amd64 $(1)-docker-per-arch-arm32 $(1)-docker-per-arch-arm64 - - $(1)-build-amd64: - ifeq (1, ${BUILD_AMD64}) - docker build $(CACHE_OPTION) -f $(DOCKERFILE_DIR)/Dockerfile.$(2) . -t $(PREFIX)/$(2):$(LABEL_PREFIX)-$(AMD64_SUFFIX) --build-arg PLATFORM=$(AMD64_SUFFIX) - endif - $(1)-build-arm32: - ifeq (1, ${BUILD_ARM32}) - docker build $(CACHE_OPTION) -f $(DOCKERFILE_DIR)/Dockerfile.$(2) . -t $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM32V7_SUFFIX) --build-arg PLATFORM=$(ARM32V7_SUFFIX) - endif - $(1)-build-arm64: - ifeq (1, ${BUILD_ARM64}) - docker build $(CACHE_OPTION) -f $(DOCKERFILE_DIR)/Dockerfile.$(2) . -t $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM64V8_SUFFIX) --build-arg PLATFORM=$(ARM64V8_SUFFIX) - endif - - $(1)-docker-per-arch-amd64: - ifeq (1, ${BUILD_AMD64}) - docker push $(PREFIX)/$(2):$(LABEL_PREFIX)-$(AMD64_SUFFIX) - endif - $(1)-docker-per-arch-arm32: - ifeq (1, ${BUILD_ARM32}) - docker push $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM32V7_SUFFIX) - endif - $(1)-docker-per-arch-arm64: - ifeq (1, ${BUILD_ARM64}) - docker push $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM64V8_SUFFIX) - endif - - $(1)-docker-multi-arch-create: - ifeq (1, ${BUILD_AMD64}) - $(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/$(2):$(LABEL_PREFIX) $(PREFIX)/$(2):$(LABEL_PREFIX)-$(AMD64_SUFFIX) - endif - ifeq (1, ${BUILD_ARM32}) - $(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/$(2):$(LABEL_PREFIX) $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM32V7_SUFFIX) - endif - ifeq (1, ${BUILD_ARM64}) - $(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/$(2):$(LABEL_PREFIX) $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM64V8_SUFFIX) - endif - - $(1)-docker-multi-arch-push: - $(ENABLE_DOCKER_MANIFEST) docker manifest push $(PREFIX)/$(2):$(LABEL_PREFIX) - -endef diff --git a/build/akri-rust-containers.mk b/build/akri-rust-containers.mk deleted file mode 100644 index ef6b8bc37..000000000 --- a/build/akri-rust-containers.mk +++ /dev/null @@ -1,49 +0,0 @@ - -# Create set of targets for rust builds -define add_rust_targets - akri-$(1): akri-build akri-docker-$(1) - akri-docker-$(1): $(1)-build $(1)-docker-per-arch $(1)-docker-multi-arch-create $(1)-docker-multi-arch-push - $(1)-build: $(1)-build-amd64 $(1)-build-arm32 $(1)-build-arm64 - $(1)-docker-per-arch: $(1)-docker-per-arch-amd64 $(1)-docker-per-arch-arm32 $(1)-docker-per-arch-arm64 - - $(1)-build-amd64: - ifeq (1, ${BUILD_AMD64}) - docker build $(CACHE_OPTION) -f $(DOCKERFILE_DIR)/Dockerfile.$(2) . -t $(PREFIX)/$(2):$(LABEL_PREFIX)-$(AMD64_SUFFIX) --build-arg PLATFORM=$(AMD64_SUFFIX) --build-arg CROSS_BUILD_TARGET=$(AMD64_TARGET) --build-arg BUILD_TYPE=$(if $(BUILD_RELEASE_FLAG),release,debug) - endif - $(1)-build-arm32: - ifeq (1, ${BUILD_ARM32}) - docker build $(CACHE_OPTION) -f $(DOCKERFILE_DIR)/Dockerfile.$(2) . -t $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM32V7_SUFFIX) --build-arg PLATFORM=$(ARM32V7_SUFFIX) --build-arg CROSS_BUILD_TARGET=$(ARM32V7_TARGET) --build-arg BUILD_TYPE=$(if $(BUILD_RELEASE_FLAG),release,debug) - endif - $(1)-build-arm64: - ifeq (1, ${BUILD_ARM64}) - docker build $(CACHE_OPTION) -f $(DOCKERFILE_DIR)/Dockerfile.$(2) . -t $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM64V8_SUFFIX) --build-arg PLATFORM=$(ARM64V8_SUFFIX) --build-arg CROSS_BUILD_TARGET=$(ARM64V8_TARGET) --build-arg BUILD_TYPE=$(if $(BUILD_RELEASE_FLAG),release,debug) - endif - - $(1)-docker-per-arch-amd64: - ifeq (1, ${BUILD_AMD64}) - docker push $(PREFIX)/$(2):$(LABEL_PREFIX)-$(AMD64_SUFFIX) - endif - $(1)-docker-per-arch-arm32: - ifeq (1, ${BUILD_ARM32}) - docker push $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM32V7_SUFFIX) - endif - $(1)-docker-per-arch-arm64: - ifeq (1, ${BUILD_ARM64}) - docker push $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM64V8_SUFFIX) - endif - - $(1)-docker-multi-arch-create: - ifeq (1, ${BUILD_AMD64}) - $(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/$(2):$(LABEL_PREFIX) $(PREFIX)/$(2):$(LABEL_PREFIX)-$(AMD64_SUFFIX) - endif - ifeq (1, ${BUILD_ARM32}) - $(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/$(2):$(LABEL_PREFIX) $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM32V7_SUFFIX) - endif - ifeq (1, ${BUILD_ARM64}) - $(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/$(2):$(LABEL_PREFIX) $(PREFIX)/$(2):$(LABEL_PREFIX)-$(ARM64V8_SUFFIX) - endif - - $(1)-docker-multi-arch-push: - $(ENABLE_DOCKER_MANIFEST) docker manifest push $(PREFIX)/$(2):$(LABEL_PREFIX) - -endef diff --git a/build/containers/Dockerfile.agent b/build/containers/Dockerfile.agent deleted file mode 100644 index f2515197a..000000000 --- a/build/containers/Dockerfile.agent +++ /dev/null @@ -1,33 +0,0 @@ -ARG PLATFORM=amd64 -ARG CROSS_BUILD_TARGET=x86_64-unknown-linux-gnu -FROM ${PLATFORM}/debian:bullseye-slim -ARG CROSS_BUILD_TARGET -ARG PLATFORM -ARG BUILD_TYPE=release -RUN echo "Creating container based on ${PLATFORM}/debian:bullseye-slim" -RUN echo "Using Rust binaries from ${CROSS_BUILD_TARGET}/${BUILD_TYPE}" - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri - -# Install crictl and openssl dependencies -RUN apt-get update && apt-get install -y --no-install-recommends libssl-dev openssl wget ca-certificates && \ - echo "Container platform target is ${PLATFORM}" && \ - if [ "$PLATFORM" = "arm32v7" ] ; \ - then export CRICTL_PLATFORM="arm" ; \ - elif [ "$PLATFORM" = "arm64v8" ] ; \ - then export CRICTL_PLATFORM="arm64" ; \ - elif [ "$PLATFORM" = "amd64" ] ; \ - then export CRICTL_PLATFORM="amd64" ; \ - else echo "no PLATFORM provided. Using amd64 for crictl" && export CRICTL_PLATFORM="amd64" ; \ - fi && \ - echo "CRICTL platform target is ${CRICTL_PLATFORM}" && \ - VERSION="v1.17.0" && \ - wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-$CRICTL_PLATFORM.tar.gz -O crictl.tar.gz && \ - tar zxvf crictl.tar.gz -C /usr/local/bin && \ - rm -f crictl.tar.gz && \ - apt-get remove -y wget ca-certificates && apt-get clean - -COPY ./target/${CROSS_BUILD_TARGET}/${BUILD_TYPE}/agent /agent -ENV RUST_LOG agent,akri_shared -ENTRYPOINT ["./agent"] diff --git a/build/containers/Dockerfile.agent-full b/build/containers/Dockerfile.agent-full deleted file mode 100644 index cd4988c24..000000000 --- a/build/containers/Dockerfile.agent-full +++ /dev/null @@ -1,32 +0,0 @@ -ARG PLATFORM=amd64 -ARG CROSS_BUILD_TARGET=x86_64-unknown-linux-gnu -FROM ${PLATFORM}/debian:bullseye-slim -ARG PLATFORM -ARG CROSS_BUILD_TARGET -ARG BUILD_TYPE=release -RUN echo "Creating container based on ${PLATFORM}/debian:bullseye-slim" -RUN echo "Using Rust binaries from ${CROSS_BUILD_TARGET}/${BUILD_TYPE}" - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri - -RUN apt-get update && apt-get install -y --no-install-recommends libssl-dev openssl wget ca-certificates && \ - echo "Container platform target is ${PLATFORM}" && \ - if [ "$PLATFORM" = "arm32v7" ] ; \ - then export CRICTL_PLATFORM="arm" ; \ - elif [ "$PLATFORM" = "arm64v8" ] ; \ - then export CRICTL_PLATFORM="arm64" ; \ - elif [ "$PLATFORM" = "amd64" ] ; \ - then export CRICTL_PLATFORM="amd64" ; \ - else echo "no PLATFORM provided. Using amd64 for crictl" && export CRICTL_PLATFORM="amd64" ; \ - fi && \ - echo "CRICTL platform target is ${CRICTL_PLATFORM}" && \ - VERSION="v1.17.0" && \ - wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-$CRICTL_PLATFORM.tar.gz -O crictl.tar.gz && \ - tar zxvf crictl.tar.gz -C /usr/local/bin && \ - rm -f crictl.tar.gz && \ - apt-get remove -y wget ca-certificates && apt-get clean - -COPY ./target/${CROSS_BUILD_TARGET}/${BUILD_TYPE}/agent-full /agent -ENV RUST_LOG agent,akri_shared,akri_debug_echo -ENTRYPOINT ["./agent"] diff --git a/build/containers/Dockerfile.anomaly-detection-app b/build/containers/Dockerfile.anomaly-detection-app deleted file mode 100644 index 87fa2ba2f..000000000 --- a/build/containers/Dockerfile.anomaly-detection-app +++ /dev/null @@ -1,19 +0,0 @@ -ARG PLATFORM=amd64 -FROM ${PLATFORM}/debian:bullseye-slim - -# Avoid tzdata prompt -ARG DEBIAN_FRONTEND=noninteractive - -WORKDIR /app -COPY ./samples/apps/anomaly-detection-app . - -RUN echo "Creating container based on ${PLATFORM}/debian:bullseye-slim" && \ - apt-get update && \ - apt-get install -y protobuf-compiler libprotoc-dev python3-pip && \ - apt-get clean && \ - pip3 install -r ./requirements.txt - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri - -CMD python3 ./anomaly_detection.py \ No newline at end of file diff --git a/build/containers/Dockerfile.controller b/build/containers/Dockerfile.controller deleted file mode 100644 index 40ac5d2cc..000000000 --- a/build/containers/Dockerfile.controller +++ /dev/null @@ -1,15 +0,0 @@ -ARG PLATFORM=amd64 -ARG CROSS_BUILD_TARGET=x86_64-unknown-linux-gnu -FROM ${PLATFORM}/debian:bullseye-slim -ARG CROSS_BUILD_TARGET -ARG BUILD_TYPE=release -RUN echo "Creating container based on ${PLATFORM}/debian:bullseye-slim" -RUN echo "Using Rust binaries from ${CROSS_BUILD_TARGET}/${BUILD_TYPE}" - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri - -RUN apt-get update && apt-get install -y --no-install-recommends libssl-dev openssl && apt-get clean -COPY ./target/${CROSS_BUILD_TARGET}/${BUILD_TYPE}/controller /controller -ENV RUST_LOG controller,akri_shared -ENTRYPOINT ["./controller"] diff --git a/build/containers/Dockerfile.debug-echo-discovery b/build/containers/Dockerfile.debug-echo-discovery deleted file mode 100644 index 8b894204d..000000000 --- a/build/containers/Dockerfile.debug-echo-discovery +++ /dev/null @@ -1,15 +0,0 @@ -ARG PLATFORM=amd64 -ARG CROSS_BUILD_TARGET=x86_64-unknown-linux-gnu -FROM ${PLATFORM}/debian:bullseye-slim -ARG CROSS_BUILD_TARGET -ARG BUILD_TYPE=release -RUN echo "Creating container based on ${PLATFORM}/debian:bullseye-slim" -RUN echo "Using Rust binaries from ${CROSS_BUILD_TARGET}/${BUILD_TYPE}" - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri - -RUN apt-get update && apt-get install -y --no-install-recommends libssl-dev openssl && apt-get clean -COPY ./target/${CROSS_BUILD_TARGET}/${BUILD_TYPE}/debug-echo-discovery-handler /debug-echo-discovery-handler -ENV RUST_LOG debug_echo_discovery_handler,akri_shared,akri_discovery_utils,akri_debug_echo -ENTRYPOINT ["./debug-echo-discovery-handler"] diff --git a/build/containers/Dockerfile.onvif-discovery b/build/containers/Dockerfile.onvif-discovery deleted file mode 100644 index 687dba9ea..000000000 --- a/build/containers/Dockerfile.onvif-discovery +++ /dev/null @@ -1,15 +0,0 @@ -ARG PLATFORM=amd64 -ARG CROSS_BUILD_TARGET=x86_64-unknown-linux-gnu -FROM ${PLATFORM}/debian:bullseye-slim -ARG CROSS_BUILD_TARGET -ARG BUILD_TYPE=release -RUN echo "Creating container based on ${PLATFORM}/debian:bullseye-slim" -RUN echo "Using Rust binaries from ${CROSS_BUILD_TARGET}/${BUILD_TYPE}" - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri - -RUN apt-get update && apt-get install -y --no-install-recommends libssl-dev openssl && apt-get clean -COPY ./target/${CROSS_BUILD_TARGET}/${BUILD_TYPE}/onvif-discovery-handler /onvif-discovery-handler -ENV RUST_LOG onvif_discovery_handler,akri_shared,akri_discovery_utils,akri_onvif -ENTRYPOINT ["./onvif-discovery-handler"] diff --git a/build/containers/Dockerfile.opcua-discovery b/build/containers/Dockerfile.opcua-discovery deleted file mode 100644 index 3fa59de49..000000000 --- a/build/containers/Dockerfile.opcua-discovery +++ /dev/null @@ -1,15 +0,0 @@ -ARG PLATFORM=amd64 -ARG CROSS_BUILD_TARGET=x86_64-unknown-linux-gnu -FROM ${PLATFORM}/debian:bullseye-slim -ARG CROSS_BUILD_TARGET -ARG BUILD_TYPE=release -RUN echo "Creating container based on ${PLATFORM}/debian:bullseye-slim" -RUN echo "Using Rust binaries from ${CROSS_BUILD_TARGET}/${BUILD_TYPE}" - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri - -RUN apt-get update && apt-get install -y --no-install-recommends libssl-dev openssl && apt-get clean -COPY ./target/${CROSS_BUILD_TARGET}/${BUILD_TYPE}/opcua-discovery-handler /opcua-discovery-handler -ENV RUST_LOG opcua_discovery_handler,akri_shared,akri_discovery_utils,akri_opcua -ENTRYPOINT ["./opcua-discovery-handler"] diff --git a/build/containers/Dockerfile.opcua-monitoring-broker b/build/containers/Dockerfile.opcua-monitoring-broker index 1e3c97885..40a2e2e08 100644 --- a/build/containers/Dockerfile.opcua-monitoring-broker +++ b/build/containers/Dockerfile.opcua-monitoring-broker @@ -1,23 +1,16 @@ -ARG BUILD_PLATFORM_TAG=3.1-bullseye -ARG OUTPUT_PLATFORM_TAG=3.1-bullseye-slim -ARG DOTNET_PUBLISH_RUNTIME=linux-x64 - -FROM mcr.microsoft.com/dotnet/sdk:${BUILD_PLATFORM_TAG} AS build -ARG BUILD_PLATFORM_TAG -RUN echo "Build base image: mcr.microsoft.com/dotnet/sdk:${BUILD_PLATFORM_TAG}" +FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:6.0-bookworm-slim AS build WORKDIR /src COPY ["samples/brokers/opcua-monitoring-broker/opcua-monitoring-broker.csproj", "."] RUN dotnet restore "opcua-monitoring-broker.csproj" COPY ["samples/brokers/opcua-monitoring-broker", "."] -ARG DOTNET_PUBLISH_RUNTIME -RUN echo "Publishing to: ${DOTNET_PUBLISH_RUNTIME}" -RUN dotnet publish -r ${DOTNET_PUBLISH_RUNTIME} "opcua-monitoring-broker.csproj" -c Release -o /app/publish +ARG TARGETARCH +RUN DOTNET_PUBLISH_RUNTIME="linux-$(echo ${TARGETARCH} | sed 's/amd/x/')"; \ + echo "Publishing to: ${DOTNET_PUBLISH_RUNTIME}" && \ + dotnet publish -r ${DOTNET_PUBLISH_RUNTIME} "opcua-monitoring-broker.csproj" -c Release -o /app/publish -FROM mcr.microsoft.com/dotnet/aspnet:${OUTPUT_PLATFORM_TAG} AS final -ARG OUTPUT_PLATFORM_TAG -RUN echo "Output base image: mcr.microsoft.com/dotnet/aspnet:${OUTPUT_PLATFORM_TAG}" +FROM mcr.microsoft.com/dotnet/aspnet:6.0-bookworm-slim AS final WORKDIR /app COPY --from=build /app/publish . diff --git a/build/containers/Dockerfile.python-app b/build/containers/Dockerfile.python-app new file mode 100644 index 000000000..00e53d8ad --- /dev/null +++ b/build/containers/Dockerfile.python-app @@ -0,0 +1,23 @@ +ARG PYTHON_VERSION=3.9 +FROM python:${PYTHON_VERSION}-bookworm + +# Avoid tzdata prompt +ARG DEBIAN_FRONTEND=noninteractive +RUN echo "Creating container based on debian:bullseye-slim for ${TARGETPLATFORM}" && \ + apt-get update && \ + apt-get install -y protobuf-compiler libprotoc-dev && \ + apt-get clean + +WORKDIR /app + +ARG APPLICATION +COPY ./samples/apps/${APPLICATION}/requirements.txt . + +RUN pip3 install --no-cache-dir -r ./requirements.txt + +COPY ./samples/apps/${APPLICATION} . + +# Link the container to the Akri repository +LABEL org.opencontainers.image.source https://github.com/project-akri/akri + +CMD [ "python3", "./app.py" ] \ No newline at end of file diff --git a/build/containers/Dockerfile.rust b/build/containers/Dockerfile.rust new file mode 100644 index 000000000..8068e93a8 --- /dev/null +++ b/build/containers/Dockerfile.rust @@ -0,0 +1,40 @@ +FROM --platform=$BUILDPLATFORM tonistiigi/xx:master AS xx + +FROM --platform=$BUILDPLATFORM rust:1.72-slim-bookworm AS build +RUN rustup component add rustfmt +RUN apt-get update && apt-get install -y clang lld protobuf-compiler pkg-config mmdebstrap wget +COPY --from=xx / / +ARG TARGETPLATFORM + +# See https://github.com/tonistiigi/xx/issues/108 +RUN sed -i -E 's/xx-clang --setup-target-triple/XX_VENDOR=\$vendor ARM_TARGET_ARCH="" xx-clang --setup-target-triple/' $(which xx-cargo) && \ + sed -i -E 's/\$\(xx-info\)-/\$\(XX_VENDOR=\$vendor ARM_TARGET_ARCH="" xx-info\)-/g' $(which xx-cargo) + +# Generate minimal runtime environment +RUN mmdebstrap --architectures=$(xx-info debian-arch) --include=libc6,libssl3,libudev1,libv4l-0,busybox --variant=extract bookworm /installroot +RUN mkdir -p /installroot/usr/local/bin /build/bin && for tool in sh uniq tail sort grep cut; do ln -s /bin/busybox /installroot/bin/$tool; done + + +RUN xx-apt-get install -y xx-c-essentials libssl-dev libudev-dev libv4l-dev pkg-config +COPY . /app +WORKDIR /app +ARG EXTRA_CARGO_ARGS +RUN XX_DEBUG_CARGO=1 xx-cargo build ${EXTRA_CARGO_ARGS} +ARG AKRI_COMPONENT +RUN PROFILE=$(echo "${EXTRA_CARGO_ARGS}" | grep -q -- --release && echo "release" || echo "debug"); \ + xx-verify ./target/$(xx-cargo --print-target-triple)/${PROFILE}/${AKRI_COMPONENT}\ + && cp ./target/$(xx-cargo --print-target-triple)/${PROFILE}/${AKRI_COMPONENT} /build/bin/akri +# Prepare crictl for agent +RUN VERSION=v1.25.0; if [ "x${AKRI_COMPONENT}" = "xagent" ]; then wget \ + "https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-$(xx-info arch).tar.gz" -O crictl.tar.gz\ + && tar zxvf crictl.tar.gz -C /build/bin; fi + + +FROM scratch +COPY --from=build /installroot / +COPY --from=build /build/bin /usr/local/bin +ENV RUST_LOG agent,akri_debug_echo,akri_discovery_utils,akri_onvif,akri_opcua,akri_shared,akri_udev\ +,controller,debug_echo_discovery_handler,onvif_discovery_handler,opcua_discovery_handler,udev_discovery_handler +# Using a fixed value here as we can't use any variable in entrypoint +ENTRYPOINT [ "/usr/local/bin/akri" ] + diff --git a/build/containers/Dockerfile.udev-discovery b/build/containers/Dockerfile.udev-discovery deleted file mode 100644 index 9f472d0de..000000000 --- a/build/containers/Dockerfile.udev-discovery +++ /dev/null @@ -1,15 +0,0 @@ -ARG PLATFORM=amd64 -ARG CROSS_BUILD_TARGET=x86_64-unknown-linux-gnu -FROM ${PLATFORM}/debian:bullseye-slim -ARG CROSS_BUILD_TARGET -ARG BUILD_TYPE=release -RUN echo "Creating container based on ${PLATFORM}/debian:bullseye-slim" -RUN echo "Using Rust binaries from ${CROSS_BUILD_TARGET}/${BUILD_TYPE}" - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri - -RUN apt-get update && apt-get install -y --no-install-recommends libssl-dev openssl && apt-get clean -COPY ./target/${CROSS_BUILD_TARGET}/${BUILD_TYPE}/udev-discovery-handler /udev-discovery-handler -ENV RUST_LOG udev-discovery-handler,akri_shared,akri_discovery_utils,akri_udev -ENTRYPOINT ["./udev-discovery-handler"] diff --git a/build/containers/Dockerfile.udev-video-broker b/build/containers/Dockerfile.udev-video-broker deleted file mode 100644 index 5866dbd4b..000000000 --- a/build/containers/Dockerfile.udev-video-broker +++ /dev/null @@ -1,20 +0,0 @@ -ARG PLATFORM=amd64 -ARG CROSS_BUILD_TARGET=x86_64-unknown-linux-gnu -FROM ${PLATFORM}/debian:bullseye-slim -ARG CROSS_BUILD_TARGET -RUN echo "Creating container based on ${PLATFORM}/debian:bullseye-slim" -RUN echo "Using Rust binaries from ${CROSS_BUILD_TARGET}" - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri - -RUN apt-get update && apt-get install -y --no-install-recommends libssl-dev openssl \ - libv4l-dev && \ - apt-get clean -COPY ./target/${CROSS_BUILD_TARGET}/release/udev-video-broker /udev-video-broker - -# Expose port used by broker service -EXPOSE 8083 - -ENV RUST_LOG udev_video_broker -ENTRYPOINT ["./udev-video-broker"] diff --git a/build/containers/Dockerfile.video-streaming-app b/build/containers/Dockerfile.video-streaming-app deleted file mode 100644 index c97a438c4..000000000 --- a/build/containers/Dockerfile.video-streaming-app +++ /dev/null @@ -1,19 +0,0 @@ -ARG PLATFORM=amd64 -FROM ${PLATFORM}/debian:bullseye-slim - -# Avoid tzdata prompt -ARG DEBIAN_FRONTEND=noninteractive - -WORKDIR /app -COPY ./samples/apps/video-streaming-app . - -RUN echo "Creating container based on ${PLATFORM}/debian:bullseye-slim" && \ - apt-get update && \ - apt-get install -y protobuf-compiler libprotoc-dev python3-pip && \ - apt-get clean && \ - pip3 install -r ./requirements.txt - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri - -CMD python3 ./streaming.py \ No newline at end of file diff --git a/build/containers/Dockerfile.webhook-configuration b/build/containers/Dockerfile.webhook-configuration deleted file mode 100644 index 58e518469..000000000 --- a/build/containers/Dockerfile.webhook-configuration +++ /dev/null @@ -1,21 +0,0 @@ -ARG PLATFORM=amd64 -ARG CROSS_BUILD_TARGET=x86_64-unknown-linux-gnu - -FROM ${PLATFORM}/debian:bullseye-slim - -ARG CROSS_BUILD_TARGET -ARG BUILD_TYPE=release -RUN echo "Creating container based on ${PLATFORM}/debian:bullseye-slim" -RUN echo "Using Rust binaries from ${CROSS_BUILD_TARGET}/${BUILD_TYPE}" - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri - -RUN apt-get update && apt-get install -y --no-install-recommends libssl-dev openssl && apt-get clean - -COPY ./target/${CROSS_BUILD_TARGET}/${BUILD_TYPE}/webhook-configuration /server - -ENV RUST_LOG agent,akri_shared - -ENTRYPOINT ["/server"] -# ENTRYPOINT ["/server", "--tls-crt-file=/path/to/crt", "--tls-key-file=/path/to/key", "--port=8443"] diff --git a/build/containers/intermediate/Dockerfile.opencvsharp-build b/build/containers/intermediate/Dockerfile.opencvsharp-build index 433c4bcda..d8a909a79 100644 --- a/build/containers/intermediate/Dockerfile.opencvsharp-build +++ b/build/containers/intermediate/Dockerfile.opencvsharp-build @@ -8,65 +8,74 @@ # A second Pull Request should subsequently be made to update # Makefile's USE_OPENCV_BASE_VERSION. # +# This Dockerfile is a port (with cross-compilation addition) of the +# official upstream Dockerfile: +# https://github.com/shimat/opencvsharp/blob/main/docker/ubuntu22-dotnet6-opencv4.8.0/Dockerfile -ARG PLATFORM= -FROM mcr.microsoft.com/dotnet/aspnet:3.1-bullseye-slim${PLATFORM} AS base -WORKDIR /app +ARG OPENCV_SHARP_VERSION="4.8.0.20230711" -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri +FROM --platform=$BUILDPLATFORM tonistiigi/xx:master AS xx -# based on https://xaviergeerinck.com/opencv-in-dotnet-core -ENV OPENCV_VERSION="4.5.4" -ENV OPENCV_INSTALLATION_DIR="/opt/opencv/" -ENV OPENCV_SHARP_VERSION="4.5.3.20210821" +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0-bookworm-slim as builder + +ENV DEBIAN_FRONTEND=noninteractive +#ENV OPENCV_VERSION=${OPENCV_SHARP_VERSION%.*} + +WORKDIR / +COPY --from=xx / / -# Install opencv dependencies RUN apt-get update && apt-get -y install --no-install-recommends \ - apt-transport-https \ - software-properties-common \ - wget \ - unzip \ - ca-certificates \ - build-essential \ - cmake \ - git \ - libtbb-dev \ - libatlas-base-dev \ - libgtk2.0-dev \ - libavcodec-dev \ - libavformat-dev \ - libswscale-dev \ - libdc1394-22-dev \ - libxine2-dev \ - libv4l-dev \ - libtheora-dev \ - libvorbis-dev \ - libxvidcore-dev \ - libopencore-amrnb-dev \ - libopencore-amrwb-dev \ - libavresample-dev \ - x264 \ - libtesseract-dev \ - libgdiplus \ - && apt-get -y clean \ - && rm -rf /var/lib/apt/lists/* + apt-transport-https \ + software-properties-common \ + wget \ + unzip \ + ca-certificates \ + build-essential \ + cmake \ + git \ + clang + +ARG TARGETPLATFORM + +# Install opencv dependencies +RUN xx-apt install -y xx-c-essentials xx-cxx-essentials \ + libtbb-dev \ + libatlas-base-dev \ + libgtk2.0-dev \ + libx11-dev \ + liblerc-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + libdc1394-dev \ + libxine2-dev \ + libv4l-dev \ + libtheora-dev \ + libvorbis-dev \ + libxvidcore-dev \ + libopencore-amrnb-dev \ + libopencore-amrwb-dev \ + x264 \ + libtesseract-dev \ + libgdiplus + +ARG OPENCV_SHARP_VERSION +# Setup opencv and opencv-contrib source +RUN OPENCV_VERSION=${OPENCV_SHARP_VERSION%.*}; \ + wget -q https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ + unzip -q ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv-${OPENCV_VERSION} opencv && \ + wget -q https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ + unzip -q ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv_contrib-${OPENCV_VERSION} opencv_contrib -RUN mkdir ${OPENCV_INSTALLATION_DIR} && \ - cd ${OPENCV_INSTALLATION_DIR} && \ - wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -Oopencv-${OPENCV_VERSION}.zip && \ - unzip opencv-${OPENCV_VERSION}.zip && \ - wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip -Oopencv_contrib-${OPENCV_VERSION}.zip && \ - unzip opencv_contrib-${OPENCV_VERSION}.zip && \ - rm ${OPENCV_INSTALLATION_DIR}/*.zip && \ - cd ${OPENCV_INSTALLATION_DIR}/opencv-${OPENCV_VERSION} - - -RUN cd ${OPENCV_INSTALLATION_DIR}/opencv-${OPENCV_VERSION} && \ - mkdir build && cd build && \ - cmake \ +# Build OpenCV +RUN cd opencv && mkdir build && cd build && \ + cmake $(xx-clang --print-cmake-defines) \ + -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ -D CMAKE_BUILD_TYPE=RELEASE \ - -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${OPENCV_VERSION}/modules \ -D BUILD_SHARED_LIBS=OFF \ -D ENABLE_CXX11=ON \ -D BUILD_EXAMPLES=OFF \ @@ -74,7 +83,7 @@ RUN cd ${OPENCV_INSTALLATION_DIR}/opencv-${OPENCV_VERSION} && \ -D BUILD_PERF_TESTS=OFF \ -D BUILD_TESTS=OFF \ -D BUILD_JAVA=OFF \ - -D BUILD_opencv_app=OFF \ + -D BUILD_opencv_apps=OFF \ -D BUILD_opencv_barcode=OFF \ -D BUILD_opencv_java_bindings_generator=OFF \ -D BUILD_opencv_js_bindings_generator=OFF \ @@ -98,62 +107,52 @@ RUN cd ${OPENCV_INSTALLATION_DIR}/opencv-${OPENCV_VERSION} && \ -D BUILD_opencv_structured_light=OFF \ -D BUILD_opencv_surface_matching=OFF \ -D BUILD_opencv_videostab=OFF \ - -D BUILD_opencv_wechat_qrcode=OFF \ + -D BUILD_opencv_wechat_qrcode=ON \ -D WITH_GSTREAMER=OFF \ -D WITH_ADE=OFF \ + -D WITH_IPP=OFF \ -D OPENCV_ENABLE_NONFREE=ON \ - .. && make -j$(nproc) && \ - make install -j8 && \ - ldconfig + .. && make -j$(nproc) && make install && ldconfig -RUN cd ${OPENCV_INSTALLATION_DIR} && \ - git clone --depth=1 --branch=${OPENCV_SHARP_VERSION} https://github.com/shimat/opencvsharp.git opencvsharp && \ - cd opencvsharp/src && \ - mkdir build && \ - cd build && \ - cmake -D CMAKE_INSTALL_PREFIX=${OPENCV_INSTALLATION_DIR} .. && \ - make -j$(nproc) && \ - make install && \ - ldconfig && \ - cp OpenCvSharpExtern/libOpenCvSharpExtern.so /usr/lib +# Download OpenCvSharp +RUN git clone --depth=1 --branch=${OPENCV_SHARP_VERSION} https://github.com/shimat/opencvsharp.git opencvsharp -# Don't force architecture here as it won't be working as expected -FROM mcr.microsoft.com/dotnet/sdk:3.1-bullseye AS build-dotnet-env +# Install the Extern lib. +RUN mkdir /opencvsharp/make && cd /opencvsharp/make && \ + cmake $(xx-clang --print-cmake-defines) -D CMAKE_INSTALL_PREFIX=/opencvsharp/make /opencvsharp/src && \ + make -j$(nproc) && make install && \ + rm -rf /opencv && \ + rm -rf /opencv_contrib && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /usr/lib/ -ARG PLATFORM - -ENV OPENCV_SHARP_VERSION="4.5.3.20210821" -ENV ARCH=${PLATFORM:--x64} - -WORKDIR / -COPY --from=base /usr/lib/libOpenCvSharpExtern.so ./ -RUN git clone --depth=1 --branch=${OPENCV_SHARP_VERSION} https://github.com/shimat/opencvsharp.git +RUN xx-verify /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so +ARG BUILDPLATFORM # Install Build the C# part of OpenCvSharp -RUN cd /opencvsharp/src/OpenCvSharp && \ - dotnet build -r linux${ARCH%32} -c Release -f netstandard2.0 +RUN DOTNET_PUBLISH_RUNTIME="linux-$(echo ${TARGETARCH} | sed 's/amd/x/')"; \ + cd /opencvsharp/src/OpenCvSharp && \ + dotnet build --no-self-contained -r ${DOTNET_PUBLISH_RUNTIME} -c Release -f net6.0 && \ + cd /opencvsharp/src/OpenCvSharp.Extensions && \ + dotnet build --no-self-contained -r ${DOTNET_PUBLISH_RUNTIME} -c Release -f net6.0 + +RUN mkdir /artifacts && cd /artifacts && \ + cp /opencvsharp/src/OpenCvSharp/bin/Release/net6.0/*/* . && \ + cp /opencvsharp/src/OpenCvSharp.Extensions/bin/Release/net6.0/*/* . -RUN cd /opencvsharp/src/OpenCvSharp.Extensions && \ - dotnet build -r linux${ARCH%32} -c Release -f netstandard2.0 +########## Final image ########## -RUN mkdir /opencvsharp/build && \ - cd /opencvsharp/build && \ - cp /opencvsharp/src/OpenCvSharp/bin/$([ -n "$PLATFORM" ] && echo "*")/Release/netstandard2.0/*/* . && \ - cp /opencvsharp/src/OpenCvSharp.Extensions/bin/$([ -n "$PLATFORM" ] && echo "*")/Release/netstandard2.0/*/* . - -# Copy over OpenCvSharp binaries and OpenCvSharpExtern shared library -FROM mcr.microsoft.com/dotnet/aspnet:3.1-bullseye-slim${PLATFORM} +FROM mcr.microsoft.com/dotnet/aspnet:6.0-bookworm-slim as final WORKDIR /app -COPY --from=build-dotnet-env /opencvsharp/build ./ -COPY --from=build-dotnet-env /libOpenCvSharpExtern.so /usr/lib # Install OpenCVSharpExtern dependencies RUN apt-get update && apt-get -y install --no-install-recommends \ libgtk2.0-dev \ libavcodec-dev \ libavformat-dev \ libswscale-dev \ - libdc1394-22-dev \ - libavresample-dev \ + libdc1394-dev \ libtesseract-dev \ && apt-get -y clean \ && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /usr/lib/libOpenCvSharpExtern.so /usr/lib +COPY --from=builder /artifacts ./ diff --git a/build/containers/intermediate/Dockerfile.rust-crossbuild-amd64 b/build/containers/intermediate/Dockerfile.rust-crossbuild-amd64 deleted file mode 100644 index 1ee0df805..000000000 --- a/build/containers/intermediate/Dockerfile.rust-crossbuild-amd64 +++ /dev/null @@ -1,20 +0,0 @@ -# -# This Dockerfile is used to create intermediate containers used -# by the Akri build. -# -# Any changes to this file need to be made in its own Pull Request -# and need include a change to Makefile's BUILD_RUST_CROSSBUILD_VERSION. -# -# A second Pull Request should subsequently be made to update -# Cross.toml to point at the new versions. -# - -FROM rustembedded/cross:x86_64-unknown-linux-gnu-0.1.16 - -RUN apt-get update && \ - apt-get install -y --no-install-recommends pkg-config \ - g++ ca-certificates curl libssl-dev \ - libv4l-dev libudev-dev protobuf-compiler - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri diff --git a/build/containers/intermediate/Dockerfile.rust-crossbuild-arm32v7 b/build/containers/intermediate/Dockerfile.rust-crossbuild-arm32v7 deleted file mode 100644 index 447430d53..000000000 --- a/build/containers/intermediate/Dockerfile.rust-crossbuild-arm32v7 +++ /dev/null @@ -1,25 +0,0 @@ -# -# This Dockerfile is used to create intermediate containers used -# by the Akri build. -# -# Any changes to this file need to be made in its own Pull Request -# and need include a change to Makefile's BUILD_RUST_CROSSBUILD_VERSION. -# -# A second Pull Request should subsequently be made to update -# Cross.toml to point at the new versions. -# - -FROM rustembedded/cross:armv7-unknown-linux-gnueabihf-0.1.16 - -RUN sed -i 's/^deb h'/'deb [arch=amd64,i386] h/' /etc/apt/sources.list && \ - dpkg --add-architecture armhf && \ - echo deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -c -s) main restricted universe multiverse >> /etc/apt/sources.list && \ - echo deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -c -s)-updates main restricted universe multiverse >> /etc/apt/sources.list && \ - echo deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -c -s)-backports main restricted universe multiverse >> /etc/apt/sources.list && \ - apt-get update && \ - apt-get install -y --no-install-recommends pkg-config:armhf \ - g++ ca-certificates curl libssl-dev:armhf \ - libv4l-dev:armhf libudev-dev:armhf protobuf-compiler:armhf - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri diff --git a/build/containers/intermediate/Dockerfile.rust-crossbuild-arm64v8 b/build/containers/intermediate/Dockerfile.rust-crossbuild-arm64v8 deleted file mode 100644 index 1088ac0b4..000000000 --- a/build/containers/intermediate/Dockerfile.rust-crossbuild-arm64v8 +++ /dev/null @@ -1,25 +0,0 @@ -# -# This Dockerfile is used to create intermediate containers used -# by the Akri build. -# -# Any changes to this file need to be made in its own Pull Request -# and need include a change to Makefile's BUILD_RUST_CROSSBUILD_VERSION. -# -# A second Pull Request should subsequently be made to update -# Cross.toml to point at the new versions. -# - -FROM rustembedded/cross:aarch64-unknown-linux-gnu-0.1.16 - -RUN sed -i 's/^deb h'/'deb [arch=amd64,i386] h/' /etc/apt/sources.list && \ - dpkg --add-architecture arm64 && \ - echo deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -c -s) main restricted universe multiverse >> /etc/apt/sources.list && \ - echo deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -c -s)-updates main restricted universe multiverse >> /etc/apt/sources.list && \ - echo deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -c -s)-backports main restricted universe multiverse >> /etc/apt/sources.list && \ - apt-get update && \ - apt-get install -y --no-install-recommends pkg-config:arm64 \ - g++ ca-certificates curl libssl-dev:arm64 \ - libv4l-dev:arm64 libudev-dev:arm64 protobuf-compiler:arm64 - -# Link the container to the Akri repository -LABEL org.opencontainers.image.source https://github.com/project-akri/akri diff --git a/build/intermediate-containers.mk b/build/intermediate-containers.mk index efdae79c0..2ae108093 100644 --- a/build/intermediate-containers.mk +++ b/build/intermediate-containers.mk @@ -1,82 +1,13 @@ - -BUILD_RUST_CROSSBUILD_VERSION = 0.0.8 - -BUILD_OPENCV_BASE_VERSION = 0.0.11 - -CROSS_VERSION = 0.1.16 +BUILD_OPENCV_BASE_VERSION = 0.1.0 # # # OPENCV: make and push the open cv intermediate images: # # To make all platforms: `make opencv-base` -# To make specific platforms: `BUILD_AMD64=1 BUILD_ARM32=0 BUILD_ARM64=1 make opencv-base` +# To make specific platforms: `PLATFORMS="amd64 arm/v7" make opencv-base` # # .PHONY: opencv-base -opencv-base: opencv-base-build opencv-base-docker-per-arch -opencv-base-build: opencv-base-build-amd64 opencv-base-build-arm32 opencv-base-build-arm64 -opencv-base-build-amd64: -ifeq (1, ${BUILD_AMD64}) -# No PLATFORM build arg for amd64 as the aspnet images for amd64 are not suffixed - docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.opencvsharp-build . -t $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(AMD64_SUFFIX) -endif -opencv-base-build-arm32: -ifeq (1, ${BUILD_ARM32}) - docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.opencvsharp-build . -t $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(ARM32V7_SUFFIX) --build-arg PLATFORM=-$(ARM32V7_SUFFIX) -endif -opencv-base-build-arm64: -ifeq (1, ${BUILD_ARM64}) - docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.opencvsharp-build . -t $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(ARM64V8_SUFFIX) --build-arg PLATFORM=-$(ARM64V8_SUFFIX) -endif -opencv-base-docker-per-arch: opencv-base-docker-per-arch-amd64 opencv-base-docker-per-arch-arm32 opencv-base-docker-per-arch-arm64 -opencv-base-docker-per-arch-amd64: -ifeq (1, ${BUILD_AMD64}) - docker push $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(AMD64_SUFFIX) -endif -opencv-base-docker-per-arch-arm32: -ifeq (1, ${BUILD_ARM32}) - docker push $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(ARM32V7_SUFFIX) -endif -opencv-base-docker-per-arch-arm64: -ifeq (1, ${BUILD_ARM64}) - docker push $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(ARM64V8_SUFFIX) -endif - -# -# -# CROSS: make and push the intermediate images for the cross building Rust: -# -# To make all platforms: `make rust-crossbuild` -# To make specific platforms: `BUILD_AMD64=1 BUILD_ARM32=0 BUILD_ARM64=1 make rust-crossbuild` -# -# -.PHONY: rust-crossbuild -rust-crossbuild: rust-crossbuild-build rust-crossbuild-docker-per-arch -rust-crossbuild-build: rust-crossbuild-build-amd64 rust-crossbuild-build-arm32 rust-crossbuild-build-arm64 -rust-crossbuild-build-amd64: -ifeq (1, $(BUILD_AMD64)) - docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.rust-crossbuild-$(AMD64_SUFFIX) . -t $(PREFIX)/rust-crossbuild:$(AMD64_TARGET)-$(CROSS_VERSION)-$(BUILD_RUST_CROSSBUILD_VERSION) -endif -rust-crossbuild-build-arm32: -ifeq (1, ${BUILD_ARM32}) - docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.rust-crossbuild-$(ARM32V7_SUFFIX) . -t $(PREFIX)/rust-crossbuild:$(ARM32V7_TARGET)-$(CROSS_VERSION)-$(BUILD_RUST_CROSSBUILD_VERSION) -endif -rust-crossbuild-build-arm64: -ifeq (1, ${BUILD_ARM64}) - docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.rust-crossbuild-$(ARM64V8_SUFFIX) . -t $(PREFIX)/rust-crossbuild:$(ARM64V8_TARGET)-$(CROSS_VERSION)-$(BUILD_RUST_CROSSBUILD_VERSION) -endif - -rust-crossbuild-docker-per-arch: rust-crossbuild-docker-per-arch-amd64 rust-crossbuild-docker-per-arch-arm32 rust-crossbuild-docker-per-arch-arm64 -rust-crossbuild-docker-per-arch-amd64: -ifeq (1, $(BUILD_AMD64)) - docker push $(PREFIX)/rust-crossbuild:$(AMD64_TARGET)-$(CROSS_VERSION)-$(BUILD_RUST_CROSSBUILD_VERSION) -endif -rust-crossbuild-docker-per-arch-arm32: -ifeq (1, ${BUILD_ARM32}) - docker push $(PREFIX)/rust-crossbuild:$(ARM32V7_TARGET)-$(CROSS_VERSION)-$(BUILD_RUST_CROSSBUILD_VERSION) -endif -rust-crossbuild-docker-per-arch-arm64: -ifeq (1, ${BUILD_ARM64}) - docker push $(PREFIX)/rust-crossbuild:$(ARM64V8_TARGET)-$(CROSS_VERSION)-$(BUILD_RUST_CROSSBUILD_VERSION) -endif +opencv-base: + docker buildx build $(COMMON_DOCKER_BUILD_ARGS) --tag "$(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)" --file $(DOCKERFILE_DIR)/Dockerfile.opencvsharp-build . \ No newline at end of file diff --git a/build/samples.mk b/build/samples.mk new file mode 100644 index 000000000..ee98add4a --- /dev/null +++ b/build/samples.mk @@ -0,0 +1,36 @@ +USE_OPENCV_BASE_VERSION = 0.0.11 + +.PHONY: samples +samples: opcua-monitoring-broker onvif-video-broker anomaly-detection-app video-streaming-app akri-udev-video-broker + +%-app: + docker buildx build $(COMMON_DOCKER_BUILD_ARGS) --build-arg APPLICATION=$@ --tag "$(PREFIX)/$@:$(LABEL_PREFIX)" --file $(DOCKERFILE_DIR)/Dockerfile.python-app . + +opcua-monitoring-broker: + docker buildx build $(COMMON_DOCKER_BUILD_ARGS) --tag "$(PREFIX)/opcua-monitoring-broker:$(LABEL_PREFIX)" --file $(DOCKERFILE_DIR)/Dockerfile.opcua-monitoring-broker . + +# Still use old-ish style for onvif-video-broker as app uses .NET 3.1 that doesn't have multi-arch manifest +onvif-video-broker: onvif-video-broker-multiarch + +onvif-video-broker-multiarch: onvif-video-broker-amd64 onvif-video-broker-arm64 onvif-video-broker-arm32 +ifeq (1, $(PUSH)) + docker buildx imagetool create --tag "$(PREFIX)/onvif-video-broker:$(LABEL_PREFIX)" +endif + +ONVIF_BUILDX_PUSH_OUTPUT = type=image,name=$(PREFIX)/onvif-video-broker,push-by-digest=true,name-canonical=true,push=true +ONVIF_BUILDX_ARGS = $(if $(LOAD), --load --tag $(PREFIX)/onvif-video-broker:$(LABEL_PREFIX)) $(if $(PUSH), --output $(ONVIF_BUILDX_PUSH_OUTPUT)) -f $(DOCKERFILE_DIR)/Dockerfile.onvif-video-broker + +onvif-video-broker-amd64: +ifneq (,or(findstring(amd64,$(PLATFORMS)), findstring(x86_64,$(PLATFORMS)))) + docker buildx build $(ONVIF_BUILDX_ARGS) $(if $(PUSH), --iidfile onvif-video-broker.sha-amd64) --build-arg OUTPUT_PLATFORM_TAG=$(USE_OPENCV_BASE_VERSION)-$(AMD64_SUFFIX) --build-arg DOTNET_PUBLISH_RUNTIME=linux-x64 . +endif + +onvif-video-broker-arm32: +ifneq (,findstring(arm/v7,$(PLATFORMS))) + docker buildx build $(ONVIF_BUILDX_ARGS) $(if $(PUSH), --iidfile onvif-video-broker.sha-arm32) --build-arg OUTPUT_PLATFORM_TAG=$(USE_OPENCV_BASE_VERSION)-$(ARM32V7_SUFFIX) --build-arg DOTNET_PUBLISH_RUNTIME=linux-arm . +endif + +onvif-video-broker-arm64: +ifneq (,or(findstring(aarch64,$(PLATFORMS)),findstring(arm64,$(PLATFORMS)))) + docker buildx build $(ONVIF_BUILDX_ARGS) $(if $(PUSH), --iidfile onvif-video-broker.sha-arm32) --build-arg OUTPUT_PLATFORM_TAG=$(USE_OPENCV_BASE_VERSION)-$(ARM64V8_SUFFIX) --build-arg DOTNET_PUBLISH_RUNTIME=linux-arm64 . +endif \ No newline at end of file diff --git a/deployment/helm/templates/webhook-configuration.yaml b/deployment/helm/templates/webhook-configuration.yaml index c8303d6d3..ea1d78d81 100644 --- a/deployment/helm/templates/webhook-configuration.yaml +++ b/deployment/helm/templates/webhook-configuration.yaml @@ -85,8 +85,6 @@ items: limits: memory: {{ .Values.webhookConfiguration.resources.memoryLimit }} cpu: {{ .Values.webhookConfiguration.resources.cpuLimit }} - command: - - /server args: - --tls-crt-file=/secrets/tls.crt - --tls-key-file=/secrets/tls.key @@ -164,4 +162,4 @@ items: - v1 - v1beta1 sideEffects: None -{{- end }} \ No newline at end of file +{{- end }} diff --git a/samples/apps/anomaly-detection-app/README.md b/samples/apps/anomaly-detection-app/README.md index f0a42e72e..e00bdea90 100644 --- a/samples/apps/anomaly-detection-app/README.md +++ b/samples/apps/anomaly-detection-app/README.md @@ -36,5 +36,5 @@ where the gRPC servers should be running. For example, if the servers are running at `localhost:80`, run the following: ```sh -CONFIGURATION_NAME="akri-opcua" AKRI_OPCUA_SVC_SERVICE_HOST=localhost AKRI_OPCUA_SVC_SERVICE_PORT_GRPC=80 python3 ./anomaly_detection.py +CONFIGURATION_NAME="akri-opcua" AKRI_OPCUA_SVC_SERVICE_HOST=localhost AKRI_OPCUA_SVC_SERVICE_PORT_GRPC=80 python3 ./app.py ``` \ No newline at end of file diff --git a/samples/apps/anomaly-detection-app/anomaly_detection.py b/samples/apps/anomaly-detection-app/app.py similarity index 100% rename from samples/apps/anomaly-detection-app/anomaly_detection.py rename to samples/apps/anomaly-detection-app/app.py diff --git a/samples/apps/video-streaming-app/README.md b/samples/apps/video-streaming-app/README.md index 849005958..1dbefcd1d 100644 --- a/samples/apps/video-streaming-app/README.md +++ b/samples/apps/video-streaming-app/README.md @@ -36,10 +36,10 @@ The streaming application works in two modes. 1. Explicitly target a set of cameras by setting `CAMERA_COUNT`, a service to target all cameras (`CAMERAS_SOURCE_SVC`), and services for each individual camera (`CAMERA1_SOURCE_SVC` to `CAMERA${CAMERA_COUNT}_SOURCE_SVC`) ```sh -CAMERA_COUNT="2" CAMERAS_SOURCE_SVC=10.2.2.2 CAMERA1_SOURCE_SVC=10.1.2.3 CAMERA2_SOURCE_SVC=10.2.3.4 python3 ./streaming.py +CAMERA_COUNT="2" CAMERAS_SOURCE_SVC=10.2.2.2 CAMERA1_SOURCE_SVC=10.1.2.3 CAMERA2_SOURCE_SVC=10.2.3.4 python3 ./app.py ``` 2. Target all services of an Akri Configuration. The application will query for services prefixed with the Configuration name. ```sh -CONFIGURATION_NAME="akri-udev" python3 ./streaming.py +CONFIGURATION_NAME="akri-udev" python3 ./app.py ``` \ No newline at end of file diff --git a/samples/apps/video-streaming-app/streaming.py b/samples/apps/video-streaming-app/app.py similarity index 100% rename from samples/apps/video-streaming-app/streaming.py rename to samples/apps/video-streaming-app/app.py diff --git a/samples/brokers/opcua-monitoring-broker/opcua-monitoring-broker.csproj b/samples/brokers/opcua-monitoring-broker/opcua-monitoring-broker.csproj index 6e2963b40..3e51b6c15 100644 --- a/samples/brokers/opcua-monitoring-broker/opcua-monitoring-broker.csproj +++ b/samples/brokers/opcua-monitoring-broker/opcua-monitoring-broker.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 diff --git a/test/e2e/test_udev.py b/test/e2e/test_udev.py index 2d80c3e03..1e9a900a0 100644 --- a/test/e2e/test_udev.py +++ b/test/e2e/test_udev.py @@ -42,7 +42,7 @@ def grouped_config(akri_version): ).items base_command = ["/bin/sh", "-c"] # This command will get the ID_PATH to use to get a device with many "subdevices" - command = "grep -hr ID_PATH= /run/udev/data | sort | uniq -cd | sort -h | tail -1 | cut -d '=' -f 2" + command = "grep -hr ID_PATH= /run/udev/data | sort | uniq -cd | sort -n | tail -1 | cut -d '=' -f 2" paths = set() # Get the ID_PATH we can use for pod in pods: @@ -60,7 +60,7 @@ def grouped_config(akri_version): try: paths.add(resp.readline_stdout(timeout=3).strip()) except: - pytest.skip("No udev ?") + pytest.skip(f"No udev ?") if len(paths) == 0: pytest.skip("No groupable devices found") path = paths.pop()