Making docker scripts more robust
This commit is contained in:
parent
efbb720adf
commit
bd24e8ffa0
@ -4,6 +4,6 @@
|
|||||||
set -x
|
set -x
|
||||||
docker compose \
|
docker compose \
|
||||||
-f fab/d/docker-compose.yaml \
|
-f fab/d/docker-compose.yaml \
|
||||||
--project-name ${REPO_NAME} \
|
-p ${REPO_NAME} \
|
||||||
--project-directory ${REPO_FOLDER} \
|
--project-directory ${REPO_FOLDER} \
|
||||||
down
|
down
|
||||||
|
|||||||
@ -26,9 +26,10 @@ if [ "$ALREADY_RUNNING" -eq 0 ];
|
|||||||
then
|
then
|
||||||
echo "Service already running, only opening shell"
|
echo "Service already running, only opening shell"
|
||||||
else
|
else
|
||||||
|
echo "Service not running, starting service"
|
||||||
docker compose \
|
docker compose \
|
||||||
-f fab/d/docker-compose.yaml \
|
-f fab/d/docker-compose.yaml \
|
||||||
--project-name ${REPO_NAME} \
|
-p ${REPO_NAME} \
|
||||||
--project-directory ${REPO_FOLDER} \
|
--project-directory ${REPO_FOLDER} \
|
||||||
up -d
|
up -d
|
||||||
fi
|
fi
|
||||||
@ -36,6 +37,7 @@ fi
|
|||||||
echo "Connecting to docker shell and running command $COMMAND..."
|
echo "Connecting to docker shell and running command $COMMAND..."
|
||||||
docker compose \
|
docker compose \
|
||||||
-f fab/d/docker-compose.yaml \
|
-f fab/d/docker-compose.yaml \
|
||||||
--project-name ${REPO_NAME} \
|
-p ${REPO_NAME} \
|
||||||
--project-directory ${REPO_FOLDER} \
|
--project-directory ${REPO_FOLDER} \
|
||||||
exec $REPO_NAME $COMMAND
|
exec $REPO_NAME $COMMAND
|
||||||
|
|
||||||
@ -7,7 +7,7 @@
|
|||||||
NETWORK_EXISTS=0
|
NETWORK_EXISTS=0
|
||||||
#This is necessary instead of using $? (previous command exit code) as we are set -e mode,
|
#This is necessary instead of using $? (previous command exit code) as we are set -e mode,
|
||||||
#which exists the script on any error
|
#which exists the script on any error
|
||||||
docker network ls | grep ${PARENT_PROJECT} || NETWORK_EXISTS=1
|
docker network ls | grep " ${PARENT_PROJECT} " || NETWORK_EXISTS=1
|
||||||
#0 if already exists, 1 if doesn't exist (0=no error)
|
#0 if already exists, 1 if doesn't exist (0=no error)
|
||||||
|
|
||||||
if [ "$NETWORK_EXISTS" -eq 0 ];
|
if [ "$NETWORK_EXISTS" -eq 0 ];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user