tragait | 9bbcb1b | 2020-02-24 16:33:50 +0000 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | SCRIPT_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 4 | SCRIPT_NAME=$(basename $0) |
| 5 | CONFIG_DIR=$SCRIPT_HOME/config |
| 6 | ENV_FILE=$CONFIG_DIR/env |
| 7 | TEMP_DIR_PATH=$SCRIPT_HOME/temp |
| 8 | TEST_LAB_DIR_PATH=$TEMP_DIR_PATH/test_lab |
| 9 | DOCKER_COMPOSE_FILE_PATH=$SCRIPT_HOME/docker-compose.yml |
| 10 | DOCKER_COMPOSE_LOCAL_OVERRIDE_FILE=$SCRIPT_HOME/docker-compose.local.yml |
| 11 | |
| 12 | echo "Running $SCRIPT_HOME/$SCRIPT_NAME ..." |
| 13 | export $(egrep -v '^#' $ENV_FILE | xargs) |
| 14 | export TEST_LAB_DIR=$TEST_LAB_DIR_PATH |
| 15 | export CONFIG_DIR_PATH=$CONFIG_DIR |
| 16 | |
| 17 | if [ "$DOCKER_ENVIRONMENT" == "remote" ]; then |
| 18 | echo "Tearing down docker containers from remote images ..." |
| 19 | docker-compose -f $DOCKER_COMPOSE_FILE_PATH -p $PROJECT_NAME down |
| 20 | elif [ "$DOCKER_ENVIRONMENT" == "local" ]; then |
| 21 | echo "Tearing down docker containers from local images ..." |
| 22 | docker-compose -f $DOCKER_COMPOSE_FILE_PATH -f $DOCKER_COMPOSE_LOCAL_OVERRIDE_FILE -p $PROJECT_NAME down |
| 23 | else |
| 24 | echo "Couldn't find valid property for DOCKER_ENVIRONMENT in $ENV_FILE." |
| 25 | echo "Attempting normal teardown ..." |
| 26 | docker-compose -f $DOCKER_COMPOSE_FILE_PATH -p $PROJECT_NAME down |
| 27 | fi |
| 28 | |
| 29 | echo "Finished executing $SCRIPT_HOME/$SCRIPT_NAME" |