updated buildDistribution script

This commit is contained in:
Alfredo Oliviero 2024-05-13 11:24:45 +02:00
parent 56fcf28afa
commit 9fa9637a81
1 changed files with 23 additions and 14 deletions

View File

@ -3,6 +3,8 @@
set -e set -e
ACCEPTED_JAVA_VERSIONS=(11 17) ACCEPTED_JAVA_VERSIONS=(11 17)
NAME=smartgears-distribution
SMARTGEARS_VERSION=4.0.1-SNAPSHOT SMARTGEARS_VERSION=4.0.1-SNAPSHOT
JAVA_VERSION=11 JAVA_VERSION=11
@ -12,6 +14,11 @@ PUSH_HARBOR=false
LOGIN_HARBOR=false LOGIN_HARBOR=false
MULTI_PLATFORM=false MULTI_PLATFORM=false
IMAGE_VERSION=${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat${TOMCAT_VERSION}
BUILD_NAME=$NAME:$IMAGE_VERSION
echo "BUILD_NAME=$BUILD_NAME"
################################################################################ ################################################################################
# Help # # Help #
@ -63,22 +70,28 @@ do
esac esac
done done
IMAGE_VERSION=${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat${TOMCAT_VERSION}
echo "IMAGE_VERSION=$IMAGE_VERSION"
BUILD_NAME=smartgears-distribution:$IMAGE_VERSION if [ ${LOGIN_HARBOR} = true ];
then
./loginHarborHub.sh
fi
if [ -z $GOAL ]; if [ -z $GOAL ];
then mvn clean package; then
else mvn clean ${GOAL}; mvn clean package;
else
mvn clean ${GOAL};
fi fi
if [ -z $MULTI_PLATFORM ]; if [ -z $MULTI_PLATFORM ];
then docker build -t $BUILD_NAME --build-arg="JAVA_VERSION=${JAVA_VERSION}" --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" .; then
else docker build -t $BUILD_NAME --build-arg="JAVA_VERSION=${JAVA_VERSION}" --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" --platform=linux/amd64,linux/arm64,linux/arm/v7 . ; docker build -t $BUILD_NAME --build-arg="JAVA_VERSION=${JAVA_VERSION}" --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" .;
echo ">>> generated docker image ${IMAGE_VERSION}" else
docker build -t $BUILD_NAME --build-arg="JAVA_VERSION=${JAVA_VERSION}" --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" --platform=linux/amd64,linux/arm64,linux/arm/v7 . ;
fi fi
echo ">>> generated docker image ${IMAGE_VERSION}"
if [ ${PUSH_DOCKER} = true ]; if [ ${PUSH_DOCKER} = true ];
then then
@ -86,13 +99,9 @@ if [ ${PUSH_DOCKER} = true ];
docker tag $BUILD_NAME $DOCKER_NAME; docker tag $BUILD_NAME $DOCKER_NAME;
docker push $DOCKER_NAME; docker push $DOCKER_NAME;
echo ">>> pushed on dockerhub the image $DOCKER_NAME" echo ">>> pushed on dockerhub the image $DOCKER_NAME"
fi fi
if [ ${LOGIN_HARBOR} = true ];
then
./loginHarborHub.sh
fi
if [ ${PUSH_HARBOR} = true ]; if [ ${PUSH_HARBOR} = true ];
then then
@ -100,7 +109,7 @@ if [ ${PUSH_HARBOR} = true ];
echo ">>> PUSHING on hub.dev.d4science.org the image $HARBOR_NAME" echo ">>> PUSHING on hub.dev.d4science.org the image $HARBOR_NAME"
docker tag $BUILD_NAME $HARBOR_NAME; docker tag $BUILD_NAME $HARBOR_NAME;
docker push $HARBOR_NAME; docker push $HARBOR_NAME -a;
echo ">>> pushed on hub.dev.d4science.org the image $HARBOR_NAME" echo ">>> pushed on hub.dev.d4science.org the image $HARBOR_NAME"
fi fi