From 397b759fc17ecb0ba3411629172f3a2edb319a20 Mon Sep 17 00:00:00 2001 From: Logan Kennelly Date: Fri, 30 Dec 2022 15:59:13 -0800 Subject: [PATCH 1/2] Pre-create ./build/data This may be related to docker compose v2, but I found in testing that the implicit volume mapping was resulting in a directory owned by root and the test servers failed to launch. --- test.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test.sh b/test.sh index 6f2233c..55afcdb 100755 --- a/test.sh +++ b/test.sh @@ -103,6 +103,12 @@ create_navidrome_user() { clear_data_dir() { rm -rf ./build/data/* + + # Ensure the directory has our user permissions, not root. + if [ ! -d "./build/data" ] + then + mkdir ./build/data + fi } main() { From 24710eada3732131a647869f2aae3a27e429f796 Mon Sep 17 00:00:00 2001 From: Logan Kennelly Date: Fri, 30 Dec 2022 15:45:20 -0800 Subject: [PATCH 2/2] Introduce COMPOSE_BIN to control docker executable `docker-compose` was deprecated: https://docs.docker.com/compose/compose-v2/ I don't care to break anyone's existing setup, so introduce the option to run this on a v2 system with: `$ COMPOSE_BIN="docker compose" ./test.sh` resolves #5 --- test.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test.sh b/test.sh index 55afcdb..55b4526 100755 --- a/test.sh +++ b/test.sh @@ -4,6 +4,8 @@ # It wraps docker-compose to download a sample music library before creating instances of these servers, # allowing the go-subsonic tests to run fully against the sample instances. +COMPOSE_BIN=${COMPOSE_BIN:-"docker-compose"} + err() { echo "$1" >&2 exit 1 @@ -15,9 +17,10 @@ log() { echo "$(date +%Y-%m-%d\ %T) - ${SEV^^} - $*" >&2 } -for dependency in curl docker-compose; do +for dependency in curl docker; do hash "$dependency" 2>/dev/null || err "$dependency must be installed" done +$COMPOSE_BIN version 2>/dev/null || err "Docker Compose must be installed" SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" NAVIDROME_PORT=4533 @@ -115,18 +118,18 @@ main() { log info "Downloading sample music into ./build/music" download_sample_audio # Create or restart the docker containers of Airsonic and Navidrome - if [[ $(docker-compose top) ]] + if [[ $($COMPOSE_BIN top) ]] then # If the current composition is running, restart it to pick up possible changes log warn "Downing currently running docker containers" - docker-compose down + $COMPOSE_BIN down fi log info "Removing excess data" clear_data_dir log info "Configuring Airsonic" configure_airsonic # This must occur in the middle so settings aren't overwritten log info "Bringing up containers" - docker-compose up -d + $COMPOSE_BIN up -d sleep 10 log info "Creating Navidrome administrator (admin/admin)" create_navidrome_user