Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose support #1315

Merged
merged 3 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ jobs:
with:
submodules: 'recursive'
name: Checkout

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 12
- name: Build and Test
run: |
docker-compose -f docker-compose.yml -f docker-compose.build.yml build --build-arg TEST_BUILD=ON
Expand Down
1 change: 0 additions & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
64 changes: 53 additions & 11 deletions webodm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -254,15 +292,18 @@ 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
}

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(){
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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"
}
Expand All @@ -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
}

Expand Down Expand Up @@ -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"
Expand All @@ -460,6 +501,7 @@ elif [[ $1 = "rebuild" ]]; then
echo "Rebuilding WebODM..."
rebuild
elif [[ $1 = "update" ]]; then
environment_check
down
echo "Updating WebODM..."

Expand All @@ -474,7 +516,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
Expand Down