2024-03-05 14:45:39 +01:00
|
|
|
#!/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
|
2024-02-27 12:45:01 +01:00
|
|
|
|
|
|
|
NAME=smartgears-helloworld
|
|
|
|
PORT=8081
|
|
|
|
DEBUG_PORT=5001
|
2024-03-05 14:45:39 +01:00
|
|
|
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
|
2024-02-27 12:45:01 +01:00
|
|
|
|
2024-02-27 16:07:27 +01:00
|
|
|
docker build -t $NAME .
|
2024-03-05 14:45:39 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|