Skip to content
Permalink
202109
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
executable file 80 lines (67 sloc) 2.45 KB
#! /bin/bash
REPOSITORY=tier/gte
VERSION_TAG=202109
EXTRA_ARGS=
RABBITMQ_FL=
show_help() {
echo "$0 [--rabbitmq] [--sql] [--ldap] [--fg|-it] [docker args ...] <gte lesson id> [container cmd ...]"
echo " --rabbitmq: also start up a rabbitmq container, and link it as name 'rabbitmq'"
echo " --sql: Expose port 3306"
echo " --ldap: Expose port 389"
echo " --fg: Don't detach (i.e., don't run container with -d flag"
echo " -h|--help: This help message"
echo ""
echo "If no GTE lesson id number is passed in, the command will list all the available ids"
}
for arg in $*; do
case $arg in
--sql) EXTRA_ARGS="$EXTRA_ARGS -p 3306:3306"; shift;;
--ldap) EXTRA_ARGS="$EXTRA_ARGS -p 389:389"; shift;;
--rabbitmq) EXTRA_ARGS="$EXTRA_ARGS --link rabbitmq:rabbitmq"; RABBITMQ_FL=1; shift;;
--fg) is_foreground=1; shift;;
-it) is_foreground=1; EXTRA_ARGS="$EXTRA_ARGS $1"; shift;;
-h|--help) show_help; exit 0;;
-*) EXTRA_ARGS="$EXTRA_ARGS $1"; shift;;
*) break;;
esac
done
#echo args=$*
#echo EXTRA_ARGS=$EXTRA_ARGS
#echo RABBITMQ_FL=$RABBITMQ
if [ "$is_foreground" != 1 ]; then
EXTRA_ARGS="$EXTRA_ARGS -d"
fi
if [ -z "$1" ]
then
echo "Pass in which gte environment to spin up:"
# Get all container tags for tier/gte:*-2021xx
my_array=( $(docker images "$REPOSITORY" --format '{{.Tag}}' | grep -- "-$VERSION_TAG$" | sed -e "s/-$VERSION_TAG$//" | sort ) )
for i in "${my_array[@]}"
do
echo $i
done
exit 1
fi
LESSON_ID=$1
shift
# see if there is a container
CONTAINERS="$( docker ps -a | grep 'tier/gte' | awk '{print $1}' )"
# if so, then rm it
if [ ! -z "$CONTAINERS" ]; then
echo "Removing old containers"
docker rm -f $CONTAINERS
fi
if [ "$RABBITMQ_FL" == 1 ]; then
echo Removing any old rabbitmq containers
docker rm -f rabbitmq 2> /dev/null
#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
#$DIR/start-rabbitmq.sh
echo "Starting container rabbitmq:management"
docker run -d -p 15672:15672 --env RABBITMQ_NODENAME=docker-rabbit --hostname rabbitmq --name=rabbitmq rabbitmq:management
fi
# lets see which
#docker stop "$1" 2> /dev/null
#docker rm "$1" 2> /dev/null
#docker run -d -p 8443:443 --link rabbitmq:rabbitmq --name $1 tier/gte:"$1"-202106
echo "Starting container tier/gte:"$LESSON_ID"-$VERSION_TAG"
docker run -p 8443:443 $EXTRA_ARGS --name $LESSON_ID tier/gte:"$LESSON_ID"-$VERSION_TAG $*