Skip to content
Permalink
c1148a761e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
@mchyzer
Latest commit c1148a7 Feb 12, 2021 History
3 contributors

Users who have contributed to this file

@wgthom @mchyzer @credman
executable file 80 lines (67 sloc) 2.43 KB
#! /bin/bash
VERSION_TAG=202102
EXTRA_ARGS=
RABBITMQ_FL=
show_help() {
echo "$0 [--rabbitmq] [--fg|-it] [docker args ...] <gte lesson id> [container cmd ...]"
echo " --rabbitmq: also start up a rabbitmq container, and link it as name 'rabbitmq'"
echo " --fg: Don't detach (i.e., don't run container with -d flag"
echo " -h|--help: This help message"
echo " --ldap: Expose port 389"
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
#docker images tier/gte
echo "Pass in which gte environment to spin up:"
my_array=( $( docker images | grep "tier/gte.*$VERSION_TAG" | grep -v base | awk '{print $2}' | sort ) )
for i in "${my_array[@]}"
do
# strip last 7 chars (-202102)
i=${i::${#i}-7}
echo $i
done
exit 1
fi
LESSON_ID=$1
shift
# see if there is a container
CONTAINER="$( docker ps -a | grep 'tier/gte' | awk '{print $1}' )"
# if so, then rm it
if [ ! -z "$CONTAINER" ]; then
echo "Removing old containers"
docker ps -a | grep 'tier/gte' | awk '{print $1}' | xargs docker rm -f
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"-202102
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 $*