Docker compose support

pull/1315/head
Piero Toffanin 2023-03-30 10:11:13 -04:00
rodzic cc573c9364
commit 0205966093
2 zmienionych plików z 52 dodań i 12 usunięć

Wyświetl plik

@ -114,7 +114,6 @@ congrats(){
echo -e "\033[93m"
echo Open a web browser and navigate to $proto://$WO_HOST:$WO_PORT
echo -e "\033[39m"
echo -e "\033[91mNOTE:\033[39m Windows users using docker should replace localhost with the IP of their docker machine's IP. To find what that is, run: docker-machine ip") &
}
if [ "$1" = "--setup-devenv" ] || [ "$2" = "--setup-devenv" ] || [ "$1" = "--no-gunicorn" ]; then

Wyświetl plik

@ -234,11 +234,49 @@ if [[ $gpu = true ]]; then
prepare_intel_render_group
fi
# $1 = command | $2 = help_text | $3 = install_command (optional)
docker_compose="docker-compose"
check_docker_compose(){
dc_msg_ok="\033[92m\033[1m OK\033[0m\033[39m"
# Check if docker-compose exists
hash "docker-compose" 2>/dev/null || not_found=true
if [[ $not_found ]]; then
# Check if compose plugin is installed
if ! docker compose > /dev/null 2>&1; then
if [ "${platform}" = "Linux" ] && [ -z "$1" ] && [ ! -z "$HOME" ]; then
echo -e "Checking for docker compose... \033[93mnot found, we'll attempt to install it\033[39m"
check_command "curl" "Cannot automatically install docker compose. Please visit https://docs.docker.com/compose/install/" "" "silent"
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL# https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
check_docker_compose "y"
else
if [ -z "$1" ]; then
echo -e "Checking for docker compose... \033[93mnot found, please visit https://docs.docker.com/compose/install/ to install docker compose\033[39m"
else
echo -e "\033[93mCannot automatically install docker compose. Please visit https://docs.docker.com/compose/install/\033[39m"
fi
return 1
fi
else
docker_compose="docker compose"
fi
else
docker_compose="docker-compose"
fi
if [ -z "$1" ]; then
echo -e "Checking for $docker_compose... $dc_msg_ok"
fi
}
# $1 = command | $2 = help_text | $3 = install_command (optional) | $4 = silent
check_command(){
check_msg_prefix="Checking for $1... "
check_msg_result="\033[92m\033[1m OK\033[0m\033[39m"
unset not_found
hash "$1" 2>/dev/null || not_found=true
if [[ $not_found ]]; then
@ -254,7 +292,10 @@ check_command(){
fi
fi
echo -e "$check_msg_prefix $check_msg_result"
if [ -z "$4" ]; then
echo -e "$check_msg_prefix $check_msg_result"
fi
if [[ $not_found ]]; then
return 1
fi
@ -262,7 +303,7 @@ check_command(){
environment_check(){
check_command "docker" "https://www.docker.com/"
check_command "docker-compose" "Run \033[1mpip install docker-compose\033[0m" "pip install docker-compose"
check_docker_compose
}
run(){
@ -293,7 +334,7 @@ start(){
echo "Make sure to issue a $0 down if you decide to change the environment."
echo ""
command="docker-compose -f docker-compose.yml"
command="$docker_compose -f docker-compose.yml"
if [[ $WO_DEFAULT_NODES -gt 0 ]]; then
if [ "${GPU_NVIDIA}" = true ]; then
@ -365,7 +406,7 @@ start(){
}
down(){
command="docker-compose -f docker-compose.yml"
command="$docker_compose -f docker-compose.yml"
if [ "${GPU_NVIDIA}" = true ]; then
command+=" -f docker-compose.nodeodm.gpu.nvidia.yml"
@ -381,10 +422,10 @@ down(){
}
rebuild(){
run "docker-compose down --remove-orphans"
run "$docker_compose down --remove-orphans"
run "rm -fr node_modules/ || sudo rm -fr node_modules/"
run "rm -fr nodeodm/external/NodeODM || sudo rm -fr nodeodm/external/NodeODM"
run "docker-compose -f docker-compose.yml -f docker-compose.build.yml build --no-cache"
run "$docker_compose -f docker-compose.yml -f docker-compose.build.yml build --no-cache"
#run "docker images --no-trunc -aqf \"dangling=true\" | xargs docker rmi"
echo -e "\033[1mDone!\033[0m You can now start WebODM by running $0 start"
}
@ -403,7 +444,7 @@ run_tests(){
echo -e "\033[1mDone!\033[0m Everything looks in order."
else
echo "Running tests in webapp container"
run "docker-compose exec webapp /bin/bash -c \"/webodm/webodm.sh test\""
run "$docker_compose exec webapp /bin/bash -c \"/webodm/webodm.sh test\""
fi
}
@ -434,7 +475,7 @@ elif [[ $1 = "stop" ]]; then
environment_check
echo "Stopping WebODM..."
command="docker-compose -f docker-compose.yml"
command="$docker_compose -f docker-compose.yml"
if [ "${GPU_NVIDIA}" = true ]; then
command+=" -f docker-compose.nodeodm.gpu.nvidia.yml"
@ -474,7 +515,7 @@ elif [[ $1 = "update" ]]; then
fi
fi
command="docker-compose -f docker-compose.yml"
command="$docker_compose -f docker-compose.yml"
if [[ $WO_DEFAULT_NODES -gt 0 ]]; then
if [ "${GPU_NVIDIA}" = true ]; then