From 6bc3bd671418df3bfd03c03c16e6a025f46f3eca Mon Sep 17 00:00:00 2001 From: Alfredo Oliviero Date: Tue, 7 May 2024 15:02:57 +0200 Subject: [PATCH] buildDistribution.sh output --- buildDistribution.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/buildDistribution.sh b/buildDistribution.sh index ec3be55..d6d861e 100755 --- a/buildDistribution.sh +++ b/buildDistribution.sh @@ -21,8 +21,12 @@ Help() echo "-u p[u]sh image to dockerhub (with docker login already done)" echo "-h Print this [h]elp." echo + echo "to build a multiplatform image and push on d4science harbor" + echo "./buid ./buildDistribution.sh -m -l -p" } + + ################################################################################ ################################################################################ # Main program # @@ -62,21 +66,27 @@ done IMAGE_VERSION=${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat${TOMCAT_VERSION} echo "IMAGE_VERSION=$IMAGE_VERSION" +BUILD_NAME=smartgears-distribution:$IMAGE_VERSION + if [ -z $GOAL ]; then mvn clean package; else mvn clean ${GOAL}; fi if [ -z $MULTI_PLATFORM ]; - then docker build -t smartgears-distribution:$IMAGE_VERSION --build-arg JAVA_VERSION=${JAVA_VERSION} .; - else docker build -t smartgears-distribution:$IMAGE_VERSION --build-arg JAVA_VERSION=${JAVA_VERSION} --platform=linux/amd64,linux/arm64,linux/arm/v7 . ; + then docker build -t $BUILD_NAME --build-arg JAVA_VERSION=${JAVA_VERSION} .; + else docker build -t $BUILD_NAME --build-arg JAVA_VERSION=${JAVA_VERSION} --platform=linux/amd64,linux/arm64,linux/arm/v7 . ; + echo ">>> generated docker image ${IMAGE_VERSION}" fi if [ ${PUSH_DOCKER} = true ]; then - docker tag smartgears-distribution:$IMAGE_VERSION d4science/smartgears-distribution:$IMAGE_VERSION; - docker push d4science/smartgears-distribution:$IMAGE_VERSION; + DOCKER_NAME = d4science/$BUILD_NAME + docker tag $BUILD_NAME $DOCKER_NAME; + docker push $DOCKER_NAME; + echo ">>> pushed on dockerhub the image $DOCKER_NAME" + fi if [ ${LOGIN_HARBOR} = true ]; @@ -86,8 +96,9 @@ fi if [ ${PUSH_HARBOR} = true ]; then - docker tag smartgears-distribution:$IMAGE_VERSION hub.dev.d4science.org/gcube/smartgears-distribution:$IMAGE_VERSION; - docker push hub.dev.d4science.org/gcube/smartgears-distribution:$IMAGE_VERSION; + HARBOR_NAME=hub.dev.d4science.org/gcube/$BUILD_NAME + docker tag $BUILD_NAME $HARBOR_NAME; + docker push $HARBOR_NAME; + echo ">>> pushed on hub.dev.d4science.org the image $HARBOR_NAME" fi -echo "generated docker image ${IMAGE_VERSION}" \ No newline at end of file