From f6efc882a279cddb624fe2f2470797561a6997b8 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 3 Aug 2025 08:52:45 +0200 Subject: Move container-run.sh into utils/ --- container-run.sh | 76 -------------------------------------------------- utils/container-run.sh | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 76 deletions(-) delete mode 100755 container-run.sh create mode 100755 utils/container-run.sh diff --git a/container-run.sh b/container-run.sh deleted file mode 100755 index ba8deae..0000000 --- a/container-run.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh - -# A simple script to run commands (e.g. build commands) in a Docker container. -# It can be used for testing on platforms different from the host. For example, -# the command -# -# ./container-run.sh arm ./build test -# -# builds nissy and runs the unit tests in an ARM container. -# -# The containers are based on Alpine Linux and the contain the necessary tools -# to build the main library and the C++ and Python examples. They DO NOT -# contain the emscripten compiler, so they cannot be used to build the web -# version (e.g. ./build web or ./buidl webtest). -# The images are given a tag starting with 'localhost/nissy/'. -# -# See below for a list of options. - -usage() { - echo "$1" - echo "" - echo "usage: $0 PLATFORM [COMMAND]" - echo "" - echo "If COMMAND is unspecified, an interactive shell will be opened." - echo "" - echo "Available platforms:" - echo "x86 (equivalent to: x86_64, amd64)" - echo "arm (equivalent to: arm64)" - echo "" - echo "Examples:" - echo "$0 ram ./build test # Run unit tests in arm container" - exit 1 -} - -if [ -z "$1" ]; then - usage "No platform given." -fi - -case "$1" in -x86|x86_64|amd64) - p=amd64 - shift - ;; -arm|arm64) - p=arm64 - shift - ;; -*) - usage "Platform '$1' not available." - ;; -esac - -image="localhost/nissy/alpine-$p" -platform="--platform=linux/$p" -mount="--mount type=bind,src=./,dst=/nissy-core" -flags="--rm --privileged" - -dockerfile="$(mktemp)" -cat > "$dockerfile" << EOF -FROM alpine:3.22.1 -RUN apk update -RUN apk add gcc g++ clang python3 python3-dev -#COPY . ./nissy-core -RUN mkdir /nissy-core -WORKDIR /nissy-core -USER 1000:1000 -EOF - -docker build "$platform" -f "$dockerfile" -t "$image" . -rm "$dockerfile" - -if [ -z "$1" ]; then - docker run $flags $mount "$platform" -it "$image" /bin/sh -else - docker run $flags $mount "$platform" -t "$image" $@ -fi diff --git a/utils/container-run.sh b/utils/container-run.sh new file mode 100755 index 0000000..ba8deae --- /dev/null +++ b/utils/container-run.sh @@ -0,0 +1,76 @@ +#!/bin/sh + +# A simple script to run commands (e.g. build commands) in a Docker container. +# It can be used for testing on platforms different from the host. For example, +# the command +# +# ./container-run.sh arm ./build test +# +# builds nissy and runs the unit tests in an ARM container. +# +# The containers are based on Alpine Linux and the contain the necessary tools +# to build the main library and the C++ and Python examples. They DO NOT +# contain the emscripten compiler, so they cannot be used to build the web +# version (e.g. ./build web or ./buidl webtest). +# The images are given a tag starting with 'localhost/nissy/'. +# +# See below for a list of options. + +usage() { + echo "$1" + echo "" + echo "usage: $0 PLATFORM [COMMAND]" + echo "" + echo "If COMMAND is unspecified, an interactive shell will be opened." + echo "" + echo "Available platforms:" + echo "x86 (equivalent to: x86_64, amd64)" + echo "arm (equivalent to: arm64)" + echo "" + echo "Examples:" + echo "$0 ram ./build test # Run unit tests in arm container" + exit 1 +} + +if [ -z "$1" ]; then + usage "No platform given." +fi + +case "$1" in +x86|x86_64|amd64) + p=amd64 + shift + ;; +arm|arm64) + p=arm64 + shift + ;; +*) + usage "Platform '$1' not available." + ;; +esac + +image="localhost/nissy/alpine-$p" +platform="--platform=linux/$p" +mount="--mount type=bind,src=./,dst=/nissy-core" +flags="--rm --privileged" + +dockerfile="$(mktemp)" +cat > "$dockerfile" << EOF +FROM alpine:3.22.1 +RUN apk update +RUN apk add gcc g++ clang python3 python3-dev +#COPY . ./nissy-core +RUN mkdir /nissy-core +WORKDIR /nissy-core +USER 1000:1000 +EOF + +docker build "$platform" -f "$dockerfile" -t "$image" . +rm "$dockerfile" + +if [ -z "$1" ]; then + docker run $flags $mount "$platform" -it "$image" /bin/sh +else + docker run $flags $mount "$platform" -t "$image" $@ +fi -- cgit v1.3