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
ACCEPTED_JAVA_VERSIONS=(11 17)
NAME=smartgears-distribution
SMARTGEARS_VERSION=4.0.1-SNAPSHOT
JAVA_VERSION=11
@ -12,6 +14,11 @@ PUSH_HARBOR=false
LOGIN_HARBOR=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 #
@ -63,22 +70,28 @@ do
esac
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 ];
then mvn clean package;
else mvn clean ${GOAL};
then
mvn clean package;
else
mvn clean ${GOAL};
fi
if [ -z $MULTI_PLATFORM ];
then docker build -t $BUILD_NAME --build-arg="JAVA_VERSION=${JAVA_VERSION}" --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_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 . ;
echo ">>> generated docker image ${IMAGE_VERSION}"
then
docker build -t $BUILD_NAME --build-arg="JAVA_VERSION=${JAVA_VERSION}" --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_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
echo ">>> generated docker image ${IMAGE_VERSION}"
if [ ${PUSH_DOCKER} = true ];
then
@ -86,13 +99,9 @@ if [ ${PUSH_DOCKER} = true ];
docker tag $BUILD_NAME $DOCKER_NAME;
docker push $DOCKER_NAME;
echo ">>> pushed on dockerhub the image $DOCKER_NAME"
fi
if [ ${LOGIN_HARBOR} = true ];
then
./loginHarborHub.sh
fi
if [ ${PUSH_HARBOR} = true ];
then
@ -100,7 +109,7 @@ if [ ${PUSH_HARBOR} = true ];
echo ">>> PUSHING on hub.dev.d4science.org the image $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"
fi