From aafabba383f4395818321029535f2965271ce802 Mon Sep 17 00:00:00 2001 From: Kevin Biju Date: Tue, 7 May 2024 23:44:07 +0530 Subject: [PATCH 1/2] Docker + run scripts minor fixes --- dev-peerdb.sh | 36 +++++++++++++++--------------------- docker-compose-dev.yml | 1 - docker-compose.yml | 1 - run-peerdb.sh | 27 +++++++++++++++++---------- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/dev-peerdb.sh b/dev-peerdb.sh index 7c32151845..fb5da35f1b 100755 --- a/dev-peerdb.sh +++ b/dev-peerdb.sh @@ -1,33 +1,27 @@ #!/bin/sh -if test -z "$USE_PODMAN" +set -Eeu + +DOCKER="docker" +EXTRA_ARGS="--no-attach temporal --no-attach pyroscope --no-attach temporal-ui" + +if test -n "${USE_PODMAN:=}" then - if ! command -v docker &> /dev/null - then - if command -v podman-compose - then - echo "docker could not be found on PATH, using podman-compose" + # 0 is found, checking for not found so we check for podman then + if $(docker compose &>/dev/null) && [ $? -ne 0 ]; then + if $(podman compose &>/dev/null) && [ $? -eq 0 ]; then + echo "docker could not be found on PATH, using podman compose" USE_PODMAN=1 else - echo "docker could not be found on PATH" + echo "docker compose could not be found on PATH" exit 1 fi fi fi -if test -z "$USE_PODMAN" -then - DOCKER="docker compose" - EXTRA_ARGS="--no-attach temporal --no-attach pyroscope --no-attach temporal-ui" -else - DOCKER="podman-compose --podman-run-args=--replace" - EXTRA_ARGS="" -fi - -# check if peerdb_network exists if not create it -if ! $DOCKER network inspect peerdb_network &> /dev/null -then - $DOCKER network create peerdb_network +if test -n "$USE_PODMAN"; then + DOCKER="podman" + EXTRA_ARGS="--podman-run-args=--replace" fi export PEERDB_VERSION_SHA_SHORT=local-$(git rev-parse --short HEAD) -exec $DOCKER -f docker-compose-dev.yml up --build $EXTRA_ARGS +exec $DOCKER compose -f docker-compose-dev.yml up --build $EXTRA_ARGS diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index d7d93f6de9..1868c755bf 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -221,5 +221,4 @@ volumes: networks: default: - external: true name: peerdb_network diff --git a/docker-compose.yml b/docker-compose.yml index 42fa2f26fc..fb144173aa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -192,5 +192,4 @@ volumes: networks: default: - external: true name: peerdb_network diff --git a/run-peerdb.sh b/run-peerdb.sh index 002bf93679..f834000ab8 100755 --- a/run-peerdb.sh +++ b/run-peerdb.sh @@ -1,17 +1,24 @@ #!/bin/sh -set -Eeu +set -Eeux -if ! command -v docker &> /dev/null +DOCKER="docker" + +if test -n "${USE_PODMAN:=}" then - echo "docker could not be found on PATH" - exit 1 + if ! (command -v docker &> /dev/null); then + if (command -v podman &> /dev/null); then + echo "docker could not be found on PATH, using podman" + USE_PODMAN=1 + else + echo "docker could not be found on PATH" + exit 1 + fi + fi fi -# check if peerdb_network exists if not create it -if ! docker network inspect peerdb_network &> /dev/null -then - docker network create peerdb_network +if test -n "$USE_PODMAN"; then + DOCKER="podman" fi -docker compose pull -docker compose -f docker-compose.yml up --no-attach catalog --no-attach temporal --no-attach temporal-ui --no-attach temporal-admin-tools +$DOCKER compose pull +exec $DOCKER compose -f docker-compose.yml up --no-attach catalog --no-attach temporal --no-attach temporal-ui --no-attach temporal-admin-tools From 0d3f46f54ab447005171fabfd5a66544f9c05de7 Mon Sep 17 00:00:00 2001 From: Kevin Biju Date: Tue, 7 May 2024 23:45:18 +0530 Subject: [PATCH 2/2] minor typo --- run-peerdb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-peerdb.sh b/run-peerdb.sh index f834000ab8..91bce75a02 100755 --- a/run-peerdb.sh +++ b/run-peerdb.sh @@ -1,5 +1,5 @@ #!/bin/sh -set -Eeux +set -Eeu DOCKER="docker"