Skip to content

Commit

Permalink
Update deploy command
Browse files Browse the repository at this point in the history
  • Loading branch information
mesudip committed May 7, 2024
1 parent d9c5e08 commit 1152f70
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
30 changes: 26 additions & 4 deletions tests/test-infrastructure/deploy-swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## ./deploy-swarm prepare
##
set -eo pipefail
set -vx
. ./scripts/deploy-stack.sh
load_env

Expand Down Expand Up @@ -32,22 +33,43 @@ elif [ "$1" == "prepare" ]
then
## apply the enviroment to services compose file
## and deploy the stack
deploy-stack ${STACK_NAME}-services './docker-compose-services-rendered.yml'
deploy-stack ${STACK_NAME}-services './docker-compose-services.yml'

elif [ "$1" == "finalize" ]
then
## apply the environment to compose file
## deploy the govtool test infrastructure stack
deploy-stack ${STACK_NAME} './docker-compose-rendered.yml'

deploy-stack ${STACK_NAME}-base './docker-compose.yml'
elif [ "$1" == 'stack' ]
then
if [ "$#" -ne 2 ]
then
echo 'stack requires the stack name "govtool" | "services" | "test"'
else
case "$2" in
govtool)
deploy-stack ${STACK_NAME} './docker-compose.yml'
;;
services)
deploy-stack ${STACK_NAME}-services './docker-compose.yml'
;;
base)
deploy-stack ${STACK_NAME}-base './docker-compose.yml'
;;
*)
echo 'Invalid stack name. Valid options are "base", "services", or "govtool"'
;;
esac
fi
else
echo "Something is wrong with the command"
echo
echo " Usage:"
echo " $0 (prepare | destroy | finalize)"
echo " $0 (prepare | destroy | finalize | deploy)"
echo ''
echo " Options:"
echo " prepare -> deploys the services required by the test stack. i.e 'postgres' and 'reverse-proxy'"
echo " finalize -> deploys the test infrastructure services"
echo " destroy -> teardown everything except the volumes"
echo " deploy [stack_name] -> Deploy the stack."
fi
25 changes: 3 additions & 22 deletions tests/test-infrastructure/scripts/deploy-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@ function load_env(){
set +a
}

function help_deploy(){
echo "Something is wrong with the command"
echo
echo " Usage:"
echo " $0 [stack-name] [filename]"
echo
}

function deploy-stack(){
echo "++ deploy-stack" "$@"
## apply the environment to compose file
## deploy the govtool test infrastructure stack
## first argument is stack name and 2nd argument is the file name
Expand All @@ -31,17 +24,5 @@ function deploy-stack(){
FILENAME_WITHOUT_EXT="${FILENAME%.*}"
RENDERED_FILENAME="${FILENAME_WITHOUT_EXT}-rendered.${EXTENSION}"
envsubst < "$COMPOSE_FILE" > "$RENDERED_FILENAME"
echo docker stack deploy -c "$RENDERED_FILENAME" ${STACK_NAME}
}


if [ "$#" -eq 0 ]; then
exit 0
elif [ "$#" -ne 2 ];
then
help_deploy
exit 1
else
load_env
deploy-stack "$1" "$2"
fi
docker stack deploy -c "$RENDERED_FILENAME" ${STACK_NAME}
}

0 comments on commit 1152f70

Please sign in to comment.