From 6d2016d49a07f5cb3d60e4f110c2474d5cebe00e Mon Sep 17 00:00:00 2001 From: Johan Olsson Date: Fri, 1 Nov 2024 10:20:41 +0100 Subject: [PATCH] fix: docker build error based on platform --- hello-world-python/Dockerfile | 3 ++- hello-world-python/README.md | 3 +++ minimal-ml-inference/Dockerfile | 5 +++-- object-detector-python/Dockerfile | 5 +++-- opencv-qr-decoder-python/Dockerfile | 5 +++-- opencv-qr-decoder-python/README.md | 3 +++ parameter-api-python/Dockerfile | 5 +++-- pose-estimator-with-flask/Dockerfile | 5 +++-- web-server/Dockerfile | 3 ++- 9 files changed, 25 insertions(+), 12 deletions(-) diff --git a/hello-world-python/Dockerfile b/hello-world-python/Dockerfile index 2ddb9a7..68da3b4 100644 --- a/hello-world-python/Dockerfile +++ b/hello-world-python/Dockerfile @@ -1,8 +1,9 @@ # syntax=docker/dockerfile:1 ARG UBUNTU_VERSION=24.04 +ARG DEVICE_PLATFORM=linux/arm64/v8 -FROM arm64v8/ubuntu:${UBUNTU_VERSION} +FROM --platform=$DEVICE_PLATFORM ubuntu:${UBUNTU_VERSION} RUN DEBIAN_FRONTEND=noninteractive \ apt-get update && apt-get install -y --no-install-recommends \ diff --git a/hello-world-python/README.md b/hello-world-python/README.md index 89d09b4..37cff45 100755 --- a/hello-world-python/README.md +++ b/hello-world-python/README.md @@ -44,6 +44,9 @@ Define and export the application image name in `APP_NAME` for use in the Docker ```sh export APP_NAME=hello-world-python +# Install qemu to allow build for a different architecture +docker run --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes + docker build --tag $APP_NAME . ``` diff --git a/minimal-ml-inference/Dockerfile b/minimal-ml-inference/Dockerfile index 7760e06..fc5143d 100644 --- a/minimal-ml-inference/Dockerfile +++ b/minimal-ml-inference/Dockerfile @@ -4,9 +4,10 @@ ARG RUNTIME_VERSION=2.0.0 ARG REPO=axisecp ARG IMAGE=acap-runtime ARG UBUNTU_VERSION=24.04 +ARG DEVICE_PLATFORM=linux/arm64/v8 -FROM ${REPO}/${IMAGE}:${RUNTIME_VERSION}-protofiles AS proto-image -FROM arm64v8/ubuntu:${UBUNTU_VERSION} AS runtime-image +FROM --platform=$DEVICE_PLATFORM ${REPO}/${IMAGE}:${RUNTIME_VERSION}-protofiles AS proto-image +FROM --platform=$DEVICE_PLATFORM ubuntu:${UBUNTU_VERSION} AS runtime-image RUN DEBIAN_FRONTEND=noninteractive \ apt-get update && apt-get install -y --no-install-recommends \ diff --git a/object-detector-python/Dockerfile b/object-detector-python/Dockerfile index 613312d..0d1caf5 100644 --- a/object-detector-python/Dockerfile +++ b/object-detector-python/Dockerfile @@ -4,9 +4,10 @@ ARG RUNTIME_VERSION=2.0.0 ARG REPO=axisecp ARG IMAGE=acap-runtime ARG UBUNTU_VERSION=24.04 +ARG DEVICE_PLATFORM=linux/arm64/v8 -FROM ${REPO}/${IMAGE}:${RUNTIME_VERSION}-protofiles AS proto-image -FROM arm64v8/ubuntu:${UBUNTU_VERSION} AS runtime-image +FROM --platform=$DEVICE_PLATFORM ${REPO}/${IMAGE}:${RUNTIME_VERSION}-protofiles AS proto-image +FROM --platform=$DEVICE_PLATFORM ubuntu:${UBUNTU_VERSION} AS runtime-image RUN DEBIAN_FRONTEND=noninteractive \ apt-get update && apt-get install -y --no-install-recommends \ diff --git a/opencv-qr-decoder-python/Dockerfile b/opencv-qr-decoder-python/Dockerfile index b2d7ecb..c5c9640 100644 --- a/opencv-qr-decoder-python/Dockerfile +++ b/opencv-qr-decoder-python/Dockerfile @@ -4,9 +4,10 @@ ARG RUNTIME_VERSION=2.0.0 ARG REPO=axisecp ARG IMAGE=acap-runtime ARG UBUNTU_VERSION=24.04 +ARG DEVICE_PLATFORM=linux/arm64/v8 -FROM ${REPO}/${IMAGE}:${RUNTIME_VERSION}-protofiles AS proto-image -FROM arm64v8/ubuntu:${UBUNTU_VERSION} AS runtime-image +FROM --platform=$DEVICE_PLATFORM ${REPO}/${IMAGE}:${RUNTIME_VERSION}-protofiles AS proto-image +FROM --platform=$DEVICE_PLATFORM ubuntu:${UBUNTU_VERSION} AS runtime-image RUN DEBIAN_FRONTEND=noninteractive \ apt-get update && apt-get install -y --no-install-recommends \ diff --git a/opencv-qr-decoder-python/README.md b/opencv-qr-decoder-python/README.md index 9c1f44e..2c381b0 100644 --- a/opencv-qr-decoder-python/README.md +++ b/opencv-qr-decoder-python/README.md @@ -45,6 +45,9 @@ Define and export the application image name in `APP_NAME` for use in the Docker ```sh export APP_NAME=acap-opencv-qr-decoder-python +# Install qemu to allow build for a different architecture +docker run --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes + docker build --tag $APP_NAME . ``` diff --git a/parameter-api-python/Dockerfile b/parameter-api-python/Dockerfile index 516c965..9d6750b 100644 --- a/parameter-api-python/Dockerfile +++ b/parameter-api-python/Dockerfile @@ -4,9 +4,10 @@ ARG RUNTIME_VERSION=2.0.0 ARG REPO=axisecp ARG IMAGE=acap-runtime ARG UBUNTU_VERSION=24.04 +ARG DEVICE_PLATFORM=linux/arm64/v8 -FROM ${REPO}/${IMAGE}:${RUNTIME_VERSION}-protofiles AS proto-image -FROM arm64v8/ubuntu:${UBUNTU_VERSION} AS runtime-image +FROM --platform=$DEVICE_PLATFORM ${REPO}/${IMAGE}:${RUNTIME_VERSION}-protofiles AS proto-image +FROM --platform=$DEVICE_PLATFORM ubuntu:${UBUNTU_VERSION} AS runtime-image RUN DEBIAN_FRONTEND=noninteractive \ apt-get update && apt-get install -y --no-install-recommends \ diff --git a/pose-estimator-with-flask/Dockerfile b/pose-estimator-with-flask/Dockerfile index 6d65b16..da593a5 100644 --- a/pose-estimator-with-flask/Dockerfile +++ b/pose-estimator-with-flask/Dockerfile @@ -4,9 +4,10 @@ ARG RUNTIME_VERSION=2.0.0 ARG REPO=axisecp ARG IMAGE=acap-runtime ARG UBUNTU_VERSION=24.04 +ARG DEVICE_PLATFORM=linux/arm64/v8 -FROM ${REPO}/${IMAGE}:${RUNTIME_VERSION}-protofiles AS proto-image -FROM arm64v8/ubuntu:${UBUNTU_VERSION} AS runtime-image +FROM --platform=$DEVICE_PLATFORM ${REPO}/${IMAGE}:${RUNTIME_VERSION}-protofiles AS proto-image +FROM --platform=$DEVICE_PLATFORM ubuntu:${UBUNTU_VERSION} AS runtime-image RUN DEBIAN_FRONTEND=noninteractive \ apt-get update && apt-get install -y --no-install-recommends \ diff --git a/web-server/Dockerfile b/web-server/Dockerfile index bd3c230..5f58ce8 100644 --- a/web-server/Dockerfile +++ b/web-server/Dockerfile @@ -1,8 +1,9 @@ # syntax=docker/dockerfile:1 ARG UBUNTU_VERSION=24.04 +ARG DEVICE_PLATFORM=linux/arm64/v8 -FROM arm64v8/ubuntu:${UBUNTU_VERSION} as runtime-image +FROM --platform=$DEVICE_PLATFORM ubuntu:${UBUNTU_VERSION} # Setup environment variables ENV DEBIAN_FRONTEND=noninteractive