builder script

This commit is contained in:
Alfredo Oliviero 2024-05-15 17:58:13 +02:00
parent 5ad3ea2f8b
commit aff137b5ee
3 changed files with 35 additions and 47 deletions

View File

@ -2,13 +2,13 @@ ARG JAVA_VERSION=11
ARG SMARTGEARS_VERSION=4.0.0-SNAPSHOT
#FROM d4science/smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19
FROM hub.dev.d4science.org/gcube/smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19
#FROM smartgears-distribution:4.0.0-SNAPSHOT-java$JAVA_VERSION-tomcat10.1.19
#FROM hub.dev.d4science.org/gcube/smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19
FROM smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19
ARG CONTAINER_INI="./docker/container.ini"
COPY ./docker/logback.xml /etc/
COPY ${CONTAINER_INI} /etc/container.ini
COPY ./docker/*.gcubekey /tomcat/lib
COPY ./target/idm-service.war /tomcat/webapps/
COPY ${CONTAINER_INI} /etc/container.ini
EXPOSE 8080

View File

@ -3,20 +3,19 @@
# set -x # uncomment to debug script
ACCEPTED_JAVA_VERSIONs=(11 17)
NAME=idm-service
BUILD_VERSION=0.0.1-SNAPSHOT
SMARTGEARS_VERSION=4.0.1-SNAPSHOT
CONTAINER_INI="./docker/container.ini"
IMAGE_VERSION=${BUILD_VERSION}-java${JAVA_VERSION}-smartgears${SMARTGEARS_VERSION}
PORT=8080
DEBUG_PORT=5005
DEBUG=false
EXECUTE=false
TEST=false
COMPILE=true
JAVA_VERSION=11
NAME=idm-service
BUILD_VERSION=0.0.1-SNAPSHOT
SMARTGEARS_VERSION=4.0.1-SNAPSHOT
CONTAINER_INI="./docker/container.ini"
IMAGE_VERSION=${BUILD_VERSION}-java${JAVA_VERSION}-smartgears${SMARTGEARS_VERSION}
PUSH_DOCKER=false
PUSH_HARBOR=false
@ -50,6 +49,11 @@ Help() {
echo "-c arg path of the file to deploy as container.ini (default ./docker/container.ini)"
echo "-h Print this Help."
echo
echo "to compile and push to harbor registry with a custom container.ini file: "
echo " ./buildImageAndStart.sh -r -m -l -c \"./docker/container-XXX.ini\" "
echo
echo "to debug locally: "
echo " ./buildImageAndStart.sh -d "
}
################################################################################
@ -60,15 +64,17 @@ Help() {
set -e
OPTSTRING=":slmurn:p:c:ed:j:?h"
#OPTSTRING=":sn:p:d:j:?h"
OPTSTRING=":c:n:p:d:?jsmulrteh"
while getopts $OPTSTRING opt; do
# echo "Option -${opt} was triggered, Argument: ${OPTARG}"
case "${opt}" in
s) COMPILE=false && echo "compile $COMPILE" ;;
c)
CONTAINER_INI=${OPTARG}
echo "CONTAINER_INI: $CONTAINER_INI";;
c)
CONTAINER_INI=${OPTARG}
echo "CONTAINER_INI: $CONTAINER_INI"
;;
m) MULTI_PLATFORM=true ;;
n) NAME=${OPTARG} ;;
p) PORT=${OPTARG} ;;
@ -80,10 +86,9 @@ while getopts $OPTSTRING opt; do
t) TEST=true ;;
e) EXECUTE=true ;;
d)
EXECUTE=true
DEBUG=true
DEBUG_PORT=${OPTARG}
echo "debug enabled, port $DEBUG_PORT"
echo "debug enabled, port $DEBUG_PORT, execute $EXECUTE"
;;
j)
if [[ ${ACCEPTED_JAVA_VERSIONs[@]} =~ ${OPTARG} ]]; then
@ -94,10 +99,11 @@ while getopts $OPTSTRING opt; do
;;
h) Help && exit 0 ;;
# matched when an option that is expected to have an argument is passed without one
:)
# matched when an option that is expected to have an argument is passed without one
if [ ${OPTARG} = "d" ]; then
DEBUG=true
EXECUTE=true
echo "debug enabled, port $DEBUG_PORT"
else
# matched when an option that is expected to have an argument is passed without one
@ -122,15 +128,21 @@ else
echo "skipping mvn package"
fi
if [ -z $MULTI_PLATFORM ]; then
docker build -t $BUILD_NAME --build-arg="CONTAINER_INI=$CONTAINER_INI" --build-arg="JAVA_VERSION=${JAVA_VERSION}" --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" .
else
docker pull hub.dev.d4science.org/gcube/smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19
if [ $MULTI_PLATFORM ]; then
docker pull hub.dev.d4science.org/gcube/smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19
echo "build multiplatform"
docker build -t $BUILD_NAME --build-arg="CONTAINER_INI=$CONTAINER_INI" --build-arg="JAVA_VERSION=${JAVA_VERSION}" --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" --platform=linux/amd64,linux/arm64,linux/arm/v7 .
else
echo "build single platform"
docker build -t $BUILD_NAME --build-arg="CONTAINER_INI=$CONTAINER_INI" --build-arg="JAVA_VERSION=${JAVA_VERSION}" --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" .
# docker manifest create hub.dev.d4science.org/gcube/$BUILD_NAME \
# hub.dev.d4science.org/gcube/$NAME-amd64-linux:$IMAGE_VERSION \
# hub.dev.d4science.org/gcube/$NAME-arm-linux:$IMAGE_VERSION \
# hub.dev.d4science.org/gcube/$NAME-arm-linux:$IMAGE_VERSION
# hub.dev.d4science.org/gcube/$NAME-arm-linux:$IMAGE_VERSION
fi
if [ ${PUSH_DOCKER} = true ]; then
@ -153,7 +165,7 @@ if [ $PUSH_HARBOR = true ]; then
echo ">>> pushed on hub.dev.d4science.org the image $HARBOR_NAME"
fi
if [ $EXECUTE = true ]; then
if [ ${EXECUTE} = true ]; then
if [ $DEBUG = true ]; then
docker run -p $PORT:8080 -p $DEBUG_PORT:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=y" $BUILD_NAME
else

View File

@ -1,24 +0,0 @@
[node]
mode = online
hostname = idm.isti.cnr.it
protocol= http
port = 8080
infrastructure = gcube
authorizeChildrenContext = true
publicationFrequencyInSeconds = 60
[properties]
SmartGearsDistribution = 4.0.0-SNAPSHOT
SmartGearsDistributionBundle = UnBundled
[site]
country = it
location = pisa
[authorization]
factory = org.gcube.smartgears.security.defaults.DefaultAuthorizationProviderFactory
factory.endpoint = https://accounts.cloud-dev.d4science.org/auth/realms/d4science/protocol/openid-connect/token
credentials.class = org.gcube.smartgears.security.SimpleCredentials
credentials.clientID =
credentials.secret =