blob: e2fbdb77f5912c2b6e29ef0689ff9df74f31aa87 [file] [log] [blame]
tragait9bbcb1b2020-02-24 16:33:50 +00001#!/bin/bash
2
3SCRIPT_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4SCRIPT_NAME=$(basename $0)
5CONFIG_DIR=$SCRIPT_HOME/config
6ENV_FILE=$CONFIG_DIR/env
7TEMP_DIR_PATH=$SCRIPT_HOME/temp
8TEST_LAB_DIR_PATH=$TEMP_DIR_PATH/test_lab
9DOCKER_COMPOSE_FILE_PATH=$SCRIPT_HOME/docker-compose.yml
10DOCKER_COMPOSE_LOCAL_OVERRIDE_FILE=$SCRIPT_HOME/docker-compose.local.yml
11
12echo "Running $SCRIPT_HOME/$SCRIPT_NAME ..."
13export $(egrep -v '^#' $ENV_FILE | xargs)
14export TEST_LAB_DIR=$TEST_LAB_DIR_PATH
15export CONFIG_DIR_PATH=$CONFIG_DIR
16
17if [ "$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
20elif [ "$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
23else
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
27fi
28
29echo "Finished executing $SCRIPT_HOME/$SCRIPT_NAME"