Commit 2a4476b0 authored by Philip ABBET's avatar Philip ABBET

[buildout] Will now propose to download missing docker images

parent 472a3552
Pipeline #8855 passed with stage
in 5 minutes and 10 seconds
[buildout]
index = https://pypi.org/simple
parts = scripts cxx_integers_echo_algorithm
parts = scripts docker_images cxx_algorithms
extensions = mr.developer
auto-checkout = *
develop = .
......@@ -15,19 +15,16 @@ beat.backend.python = git https://gitlab.idiap.ch/beat/beat.backend.python
[scripts]
recipe = bob.buildout:scripts
[cxx_integers_echo_algorithm]
[docker_images]
recipe = collective.recipe.cmd
cmds = cd beat/core/test/prefix/algorithms/user/
tar -cf cxx_integers_echo.tar cxx_integers_echo/
docker run -dti --name build docker.idiap.ch/beat/beat.env.client:1.0.0 > /dev/null
docker cp cxx_integers_echo.tar build:/tmp/cxx_integers_echo.tar
docker exec build bash -c 'cd /tmp ; tar -xf /tmp/cxx_integers_echo.tar'
docker exec build bash -c 'cd /tmp/cxx_integers_echo ; mkdir build ; cd build ; cmake .. ; make'
docker cp build:/tmp/cxx_integers_echo/1.so cxx_integers_echo/.
docker stop build > /dev/null
docker rm build > /dev/null
rm cxx_integers_echo.tar
cd ../../../../../..
uninstall_cmds = rm -f beat/core/test/prefix/algorithms/user/cxx_integers_echo/1.so
cmds = ./buildout_pull_images.sh
uninstall_cmds =
on_install = true
on_update = true
[cxx_algorithms]
recipe = collective.recipe.cmd
cmds = ./buildout_compile_cxx_algorithm.sh build
uninstall_cmds = ./buildout_compile_cxx_algorithm cleanup
on_install = true
on_update = true
#! /bin/bash
ALGORITHMS_ROOT="beat/core/test/prefix/algorithms/user"
DOCKER_IMAGE="docker.idiap.ch/beat/beat.env.client:1.0.0"
BEAT_CORE_PATH=$(dirname "$0")
cd $BEAT_CORE_PATH
# Compilation of the algorithm
if [ "$1" == "build" ]; then
cd $ALGORITHMS_ROOT
tar -cf cxx_integers_echo.tar cxx_integers_echo/
docker run -dti --name build $DOCKER_IMAGE > /dev/null
docker cp cxx_integers_echo.tar build:/tmp/cxx_integers_echo.tar
docker exec build bash -c 'cd /tmp ; tar -xf /tmp/cxx_integers_echo.tar'
docker exec build bash -c 'cd /tmp/cxx_integers_echo ; mkdir build ; cd build ; cmake .. ; make'
docker cp build:/tmp/cxx_integers_echo/1.so cxx_integers_echo/.
docker stop build > /dev/null
docker rm build > /dev/null
rm cxx_integers_echo.tar
fi
# Cleanup of the compiled algorithms
if [ "$1" == "clean" ]; then
rm -f "$ALGORITHMS_ROOT/cxx_integers_echo/1.so"
fi
#! /bin/bash
IMAGES=(
docker.idiap.ch/beat/beat.env.system.python:system
docker.idiap.ch/beat/beat.env.db.examples:1.0.0
docker.idiap.ch/beat/beat.env.cxx:1.0.1
docker.idiap.ch/beat/beat.env.client:1.0.0
)
# Find all the missing images
declare -a MISSING_IMAGES
for IMAGE in ${IMAGES[@]}; do
IMAGE_HASH=$(docker images -q $IMAGE)
if [ -z "$IMAGE_HASH" ]; then
MISSING_IMAGES+=($IMAGE)
fi
done
# If there are some images missing, ask the user if he wants to download them
if [ ${#MISSING_IMAGES[@]} -gt 0 ]; then
echo "--------------------------------------------------------------------------------------"
echo "The following docker images are required (at least for the tests), but were not found:"
echo
for IMAGE in ${MISSING_IMAGES[@]}; do
echo " - $IMAGE"
done
echo
read -p "Do you want to install them now? (yes/no) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Log in the registry if needed
if ! grep -q "docker.idiap.ch" ~/.docker/config.json ; then
docker login docker.idiap.ch
fi
# Pull the images
for IMAGE in ${MISSING_IMAGES[@]}; do
echo
CMD="docker pull $IMAGE"
echo "> $CMD"
$CMD
done
fi
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment