script improved

This commit is contained in:
lucio 2024-03-05 14:45:39 +01:00
parent 42ae8c5d3d
commit c91ac3810b
2 changed files with 50 additions and 11 deletions

View File

@ -1,8 +1,56 @@
mvn clean package
#!/bin/bash
################################################################################
# Help #
################################################################################
Help()
{
# Display Help
echo "build, create and run in docker the helloworld service"
echo
echo "Syntax: buildDistribution [-n arg] [-p arg] [-d|h]"
echo "options:"
echo "n arg specifies the docker image name (default is smartgears-helloworld)."
echo "p arg specifies the port to be exposed for the docker container to access the service (default 8081)"
echo "d enable java debug mode"
echo "h Print this Help."
echo
}
################################################################################
################################################################################
# Main program #
################################################################################
################################################################################
set -e
NAME=smartgears-helloworld
PORT=8081
DEBUG_PORT=5001
debug=false
while getopts n:p:dh flag
do
case "${flag}" in
n) NAME=${OPTARG};;
p) PORT=${OPTARG};;
d) debug=true ;;
h) Help
exit 0 ;;
*) echo "Invalid option"
exit 1 ;;
esac
done
mvn clean package
docker build -t $NAME .
docker run -p $PORT:8080 $NAME
if [ $debug = false ] ; then
docker run -p $PORT:8080 $NAME ;
else
docker run -p $PORT:8080 -p $DEBUG_PORT:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=y" $NAME;
fi

View File

@ -1,9 +0,0 @@
mvn clean package
NAME=smartgears-helloworld
PORT=8081
DEBUG_PORT=5001
docker build -t $NAME .
docker run -p $PORT:8080 -p $DEBUG_PORT:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=y" $NAME