build and config

This commit is contained in:
Alfredo Oliviero 2024-05-24 16:34:54 +02:00
parent 1afbb2ecb8
commit 31340fb85e
3 changed files with 15 additions and 18 deletions

View File

@ -16,8 +16,6 @@ FROM hub.dev.d4science.org/gcube/smartgears-distribution:${SMARTGEARS_VERSION}-j
ARG MVN_FINALNAME ARG MVN_FINALNAME
ARG MVN_NAME ARG MVN_NAME
RUN apt-get update
RUN apt-get install unzip
#FROM smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19 #FROM smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19
COPY ./dockerize/configuration/logback.xml /etc/ COPY ./dockerize/configuration/logback.xml /etc/

View File

@ -13,6 +13,8 @@ EXECUTE=false
TEST=false TEST=false
COMPILE=true COMPILE=true
GOAL="clean package"
PUSH_DOCKER=false PUSH_DOCKER=false
PUSH_HARBOR=false PUSH_HARBOR=false
LOGIN_HARBOR=false LOGIN_HARBOR=false
@ -28,6 +30,7 @@ Help() {
echo "options:" echo "options:"
echo "-e execute the docker image" echo "-e execute the docker image"
echo "-g arg specifies the maven [g]oals {package, install, deploy etc} default is $GOAL."
echo "-d arg? enable java debug mode for execution" echo "-d arg? enable java debug mode for execution"
echo "-r push image to d4science harbo[r] (with login already done, or -l to login)" echo "-r push image to d4science harbo[r] (with login already done, or -l to login)"
@ -65,12 +68,13 @@ Help() {
set -e set -e
#OPTSTRING=":sn:p:d:j:?h" #OPTSTRING=":sn:p:d:j:?h"
OPTSTRING=":c:n:p:d:?jsmulrteh" OPTSTRING=":c:n:p:g:d:?jsmulrteh"
while getopts $OPTSTRING opt; do while getopts $OPTSTRING opt; do
# echo "Option -${opt} was triggered, Argument: ${OPTARG}" # echo "Option -${opt} was triggered, Argument: ${OPTARG}"
case "${opt}" in case "${opt}" in
s) COMPILE=false && echo "compile $COMPILE" ;; s) COMPILE=false && echo "compile $COMPILE" ;;
g) GOAL=${OPTARG} ;;
c) c)
CONTAINER_INI=${OPTARG} CONTAINER_INI=${OPTARG}
echo "CONTAINER_INI: $CONTAINER_INI" echo "CONTAINER_INI: $CONTAINER_INI"
@ -119,13 +123,12 @@ while getopts $OPTSTRING opt; do
done done
if [ $COMPILE = true ]; then if [ $COMPILE = true ]; then
cd .. SKIP_TEST=""
if [ $TEST = false ]; then if [ $TEST = false ]; then
mvn clean package -Dmaven.test.skip SKIP_TEST="-Dmaven.test.skip"
else
mvn clean package
fi fi
cd -
( cd .. && mvn $GOAL $SKIP_TEST );
else else
echo "skipping mvn package" echo "skipping mvn package"
fi fi
@ -139,17 +142,15 @@ if [ $MULTI_PLATFORM ]; then
fi fi
echo "DOCKER_BUILD_NAME: $DOCKER_BUILD_NAME" echo "DOCKER_BUILD_NAME: $DOCKER_BUILD_NAME"
cd ..
docker build -t $DOCKER_BUILD_NAME \ ( cd .. && docker build -t $DOCKER_BUILD_NAME \
--build-arg="MVN_FINALNAME=$MVN_FINALNAME" \ --build-arg="MVN_FINALNAME=$MVN_FINALNAME" \
--build-arg="MVN_NAME=${MVN_NAME}" \ --build-arg="MVN_NAME=${MVN_NAME}" \
--build-arg="CONTAINER_INI=${CONTAINER_INI}" \ --build-arg="CONTAINER_INI=${CONTAINER_INI}" \
--build-arg="JAVA_VERSION=${JAVA_VERSION}" \ --build-arg="JAVA_VERSION=${JAVA_VERSION}" \
--build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" \ --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" \
-f Dockerfile \ -f Dockerfile \
$PLATFORMS . $PLATFORMS . );
cd -
if [ ${PUSH_DOCKER} = true ]; then if [ ${PUSH_DOCKER} = true ]; then
docker tag $DOCKER_BUILD_NAME $DOCKER_IMAGE_NAME docker tag $DOCKER_BUILD_NAME $DOCKER_IMAGE_NAME

View File

@ -14,19 +14,17 @@ import os
# import sys # import sys
# sys.path.insert(0, os.path.abspath('.')) # sys.path.insert(0, os.path.abspath('.'))
_pom_path = "../.." _POM_PATH = "../.."
def getMvnVariable(variable): def getMvnVariable(variable):
cmd = """cd %s && mvn -q \ cmd = """cd %s && mvn -q \
-Dexec.executable=echo \ -Dexec.executable=echo \
-Dexec.args='${project.%s}' \ -Dexec.args='${project.%s}' \
--non-recursive \ --non-recursive \
exec:exec""" % (_pom_path, variable) exec:exec""" % (_POM_PATH, variable)
stream = os.popen(cmd) stream = os.popen(cmd)
return stream.read().strip() return stream.read().strip()
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
# The full version, including alpha/beta/rc tags # The full version, including alpha/beta/rc tags
release = getMvnVariable("version") release = getMvnVariable("version")