reorganizing project structure and scripts

This commit is contained in:
Luca Frosini 2024-05-24 14:19:55 +02:00
parent 1c8b0df036
commit 26a5d9df4b
23 changed files with 190 additions and 92 deletions

View File

@ -3,6 +3,6 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v0.0.1-SNAPSHOT] ## [v1.0.0-SNAPSHOT]
- First Release - First Release

View File

@ -4,6 +4,7 @@
# --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 \
# $PLATFORMS . # $PLATFORMS .
ARG JAVA_VERSION ARG JAVA_VERSION
@ -11,7 +12,7 @@ ARG SMARTGEARS_VERSION
#FROM d4science/smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19 #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 hub.dev.d4science.org/gcube/smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19
ARG CONTAINER_INI="./docker/container.ini" ARG CONTAINER_INI="./dockerize/configuration/container.ini"
ARG MVN_FINALNAME ARG MVN_FINALNAME
ARG MVN_NAME ARG MVN_NAME
@ -19,8 +20,8 @@ FROM hub.dev.d4science.org/gcube/smartgears-distribution:${SMARTGEARS_VERSION}-j
RUN apt-get install unzip 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 ./docker/logback.xml /etc/ COPY ./dockerize/configuration/logback.xml /etc/
COPY ./docker/*.gcubekey /tomcat/lib COPY ./dockerize/configuration/*.gcubekey /tomcat/lib
COPY ./target/${MVN_FINALNAME}.war /tmp COPY ./target/${MVN_FINALNAME}.war /tmp
RUN unzip /tmp/${MVN_FINALNAME}.war -d /tomcat/webapps/${MVN_NAME} RUN unzip /tmp/${MVN_FINALNAME}.war -d /tomcat/webapps/${MVN_NAME}
COPY ${CONTAINER_INI} /etc/container.ini COPY ${CONTAINER_INI} /etc/container.ini

View File

@ -4,17 +4,18 @@
start the docker container start the docker container
```sh ```sh
./buildImageAndStart.sh -e
cd dockerize && ./buildImageAndStart.sh -e
``` ```
debug the docker container (read [### DEBUG] for details) debug the docker container (read [### DEBUG] for details)
```sh ```sh
./buildImageAndStart.sh -d cd dockerize && ./buildImageAndStart.sh -d
``` ```
to compile and push to harbor registry with a custom container.ini file: to compile and push to harbor registry with a custom container.ini file:
```sh ```sh
./buildImageAndStart.sh -r -m -l -c "./docker/container-XXX.ini" cd dockerize && ./buildImageAndStart.sh -r -m -l -c "./docker/container-XXX.ini"
``` ```
### Test URLs ### Test URLs
@ -42,7 +43,7 @@ curl -l 'http://localhost:8080/helloworld/gcube/resource/health'
### Debug ### Debug
start the docker container in debug Mode start the docker container in debug Mode
```./buildImageAndStartWithDebug.sh``` ```cd dockerize && ./buildImageAndStartWithDebug.sh -d```
connect the JAVA debugger to port 5005 connect the JAVA debugger to port 5005
@ -158,11 +159,11 @@ connect the JAVA debugger to port 5005
* <scm> ??? * <scm> ???
* <dependencyManagement> gcube dependency manager * <dependencyManagement> gcube dependency manager
* docker folder: folder with the configurations for the exevution of the application. are copied in the docker container during building * dockerize/configuration folder: folder with the configurations for the exevution of the application. are copied in the docker container during building
* docker/container.ini: configurations for the docker container. * dockerize/configuration/container.ini: configurations for the docker container.
* create your own configuration copying an existing template * create your own configuration copying an existing template
* the default execution uses docker/docker/container.ini, it can be a simlink to a custom config * the default execution uses dockerize/configuration/container.ini, it can be a simlink to a custom config
* gitignore ignores all container*.ini files in the folder excepting container.default.ini * gitignore ignores all container*.ini files in the folder excepting container.default.ini
* *
* mode: [online/offline]: register the service on IS. use offline for local docker instances * mode: [online/offline]: register the service on IS. use offline for local docker instances

View File

@ -2,7 +2,7 @@
# set -x # uncomment to debug script # set -x # uncomment to debug script
set -a set -a
. ./build_conf source ./build_conf
set +a set +a
ACCEPTED_JAVA_VERSIONs=(11 17) ACCEPTED_JAVA_VERSIONs=(11 17)
@ -119,11 +119,13 @@ while getopts $OPTSTRING opt; do
done done
if [ $COMPILE = true ]; then if [ $COMPILE = true ]; then
cd ..
if [ $TEST = false ]; then if [ $TEST = false ]; then
mvn clean package -Dmaven.test.skip mvn clean package -Dmaven.test.skip
else else
mvn clean package mvn clean package
fi fi
cd -
else else
echo "skipping mvn package" echo "skipping mvn package"
fi fi
@ -137,13 +139,17 @@ 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 \ 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 \
$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

@ -1,41 +1,55 @@
MVN_VERSION=$(mvn -q \ MVN_VERSION=$(cd .. && mvn -q \
-Dexec.executable=echo \ -Dexec.executable=echo \
-Dexec.args='${project.version}' \ -Dexec.args='${project.version}' \
--non-recursive \ --non-recursive \
exec:exec) exec:exec)
echo "MVN_VERSION: ${MVN_VERSION}"
MVN_NAME=$(cd .. && mvn -q \
MVN_NAME=$(mvn -q \
-Dexec.executable=echo \ -Dexec.executable=echo \
-Dexec.args='${project.artifactId}' \ -Dexec.args='${project.artifactId}' \
--non-recursive \ --non-recursive \
exec:exec) exec:exec)
echo "MVN_NAME: ${MVN_NAME}"
MVN_FINALNAME=$(mvn -q \ MVN_FINALNAME=$(cd .. && mvn -q \
-Dexec.executable=echo \ -Dexec.executable=echo \
-Dexec.args='${project.build.finalName}' \ -Dexec.args='${project.build.finalName}' \
--non-recursive \ --non-recursive \
exec:exec) exec:exec)
echo "MVN_FINALNAME: ${MVN_FINALNAME}"
JAVA_VERSION=$(mvn -q \ JAVA_VERSION=$(cd .. && mvn -q \
-Dexec.executable=echo \ -Dexec.executable=echo \
-Dexec.args='${maven.compiler.target}' \ -Dexec.args='${maven.compiler.target}' \
--non-recursive \ --non-recursive \
exec:exec) exec:exec)
echo "JAVA_VERSION: ${JAVA_VERSION}"
TOMCAT_VERSION=tomcat10.1.19 TOMCAT_VERSION=tomcat10.1.19
SMARTGEARS_VERSION=$(mvn -q \ echo "TOMCAT_VERSION: ${TOMCAT_VERSION}"
SMARTGEARS_VERSION=$(cd .. && mvn -q \
-Dexec.executable=echo \ -Dexec.executable=echo \
-Dexec.args='${docker.smartgear.version}' \ -Dexec.args='${docker.smartgear.version}' \
--non-recursive \ --non-recursive \
exec:exec) exec:exec)
echo "SMARTGEARS_VERSION: ${SMARTGEARS_VERSION}"
CONTAINER_INI="./docker/container.ini" CONTAINER_INI="./dockerize/configuration/container.ini"
echo "CONTAINER_INI: ${CONTAINER_INI}"
IMAGE_VERSION=${MVN_VERSION}-java${JAVA_VERSION}-smartgears${SMARTGEARS_VERSION} IMAGE_VERSION=${MVN_VERSION}-java${JAVA_VERSION}-smartgears${SMARTGEARS_VERSION}
echo "IMAGE_VERSION: ${IMAGE_VERSION}"
DOCKER_BUILD_NAME=$MVN_NAME:$IMAGE_VERSION DOCKER_BUILD_NAME=$MVN_NAME:$IMAGE_VERSION
echo "DOCKER_BUILD_NAME: ${DOCKER_BUILD_NAME}"
SMARTGEAR_IMAGE=hub.dev.d4science.org/gcube/smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-${TOMCAT_VERSION} SMARTGEAR_IMAGE=hub.dev.d4science.org/gcube/smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-${TOMCAT_VERSION}
echo "SMARTGEAR_IMAGE: ${SMARTGEAR_IMAGE}"
DOCKER_IMAGE_NAME=d4science/$DOCKER_BUILD_NAME DOCKER_IMAGE_NAME=d4science/$DOCKER_BUILD_NAME
echo "DOCKER_IMAGE_NAME: ${DOCKER_IMAGE_NAME}"
HARBOR_IMAGE_NAME=hub.dev.d4science.org/gcube/$DOCKER_BUILD_NAME HARBOR_IMAGE_NAME=hub.dev.d4science.org/gcube/$DOCKER_BUILD_NAME
echo "HARBOR_IMAGE_NAME: ${HARBOR_IMAGE_NAME}"

View File

@ -4,8 +4,8 @@
xsi:noNamespaceSchemaLocation="http://enunciate.webcohesion.com/schemas/enunciate-2.14.0.xsd"> xsi:noNamespaceSchemaLocation="http://enunciate.webcohesion.com/schemas/enunciate-2.14.0.xsd">
<description package="org.gcube.service.idm" /> <description package="org.gcube.service.idm" />
<api-classes> <api-classes>
<include pattern="org.gcube.service.helloword.rest.*" /> <include pattern="org.gcube.service.helloworld.rest.*" />
<exclude pattern="org.gcube.service.helloword.*" /> <exclude pattern="org.gcube.service.helloworld.*" />
</api-classes> </api-classes>
<modules> <modules>
<gwt-json-overlay disabled="true" /> <gwt-json-overlay disabled="true" />

View File

@ -16,7 +16,7 @@ import os
def getVersion(): def getVersion():
cmd = """cd .. && \ cmd = """cd ../.. && \
mvn -q \ mvn -q \
-Dexec.executable=echo \ -Dexec.executable=echo \
-Dexec.args='${project.version}' \ -Dexec.args='${project.version}' \
@ -27,9 +27,9 @@ def getVersion():
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
project = 'gCube Catalogue (gCat) Service' project = 'gCube Hello World Service SG4'
copyright = '2022, Luca Frosini (ISTI-CNR)' copyright = '2024, gCube System'
author = 'Luca Frosini (ISTI-CNR)' author = 'Luca Frosini (ISTI-CNR), Lucio Lelii (ISTI-CNR), Alfredo Oliviero (ISTI-CNR)'
# The full version, including alpha/beta/rc tags # The full version, including alpha/beta/rc tags
release = getVersion() release = getVersion()

View File

@ -7,3 +7,4 @@ excludes:
- path: /guest - path: /guest
- path: /guest/* - path: /guest/*
- path: /api-docs/* - path: /api-docs/*
- path: /docs/*

193
pom.xml
View File

@ -2,19 +2,81 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.service</groupId>
<artifactId>helloworld</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Smartgears HelloWorld Service</name>
<packaging>war</packaging>
<parent> <parent>
<groupId>org.gcube.tools</groupId> <groupId>org.gcube.tools</groupId>
<artifactId>maven-parent</artifactId> <artifactId>maven-parent</artifactId>
<version>1.2.0</version> <version>1.2.0</version>
</parent> </parent>
<groupId>org.gcube.service</groupId>
<artifactId>helloworld</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Smartgears 4 HelloWorld Service</name>
<description>
</description>
<packaging>war</packaging>
<organization>
<name>gCube System</name>
<url>https://www.gcube-system.org/</url>
</organization>
<developers>
<developer>
<id>luca.frosini</id>
<name>Luca Frosini</name>
<email>luca.frosini@isti.cnr.it</email>
<url>https://www.isti.cnr.it/en/about/people-detail/141/Frosini_Luca</url>
<organization>ISTI-CNR</organization>
<organizationUrl>https://www.isti.cnr.it/</organizationUrl>
<roles>
<role>researcher</role>
<role>developer</role>
</roles>
<timezone>Europe/Rome</timezone>
<properties>
<picUrl>https://gravatar.com/lucafrosini</picUrl>
</properties>
</developer>
<developer>
<id>lucio.lelii</id>
<name>Lucio Lelii</name>
<email>lucio.lelii@isti.cnr.it</email>
<url></url>
<organization>ISTI-CNR</organization>
<organizationUrl>https://www.isti.cnr.it/en/about/people-detail/184/Lelii_Lucio/</organizationUrl>
<roles>
<role>researcher</role>
<role>developer</role>
</roles>
<timezone>Europe/Rome</timezone>
<properties>
<picUrl>https://gravatar.com/latinswing</picUrl>
</properties>
</developer>
<developer>
<id>alfredo.oliviero</id>
<name>Alfredo Oliviero</name>
<email>alfredo.oliviero@isti.cnr.it</email>
<url></url>
<organization>ISTI-CNR</organization>
<organizationUrl>https://www.isti.cnr.it/en/about/people-detail/1087/Oliviero_Alfredo/</organizationUrl>
<roles>
<role>researcher</role>
<role>developer</role>
</roles>
<timezone>Europe/Rome</timezone>
<properties>
<picUrl>https://gravatar.com/alfredooliviero</picUrl>
</properties>
</developer>
</developers>
<properties> <properties>
<java.version>11</java.version> <java.version>11</java.version>
@ -24,15 +86,17 @@
<!-- OPTIONAL. for authorization-control-library --> <!-- OPTIONAL. for authorization-control-library -->
<aspectj-plugin.version>1.14.0</aspectj-plugin.version> <aspectj-plugin.version>1.14.0</aspectj-plugin.version>
<enunciate.version>2.16.1</enunciate.version> <enunciate.version>2.16.1</enunciate.version>
<docker.smartgear.version>4.0.1-SNAPSHOT</docker.smartgear.version> <docker.smartgear.version>4.0.1-SNAPSHOT</docker.smartgear.version>
</properties> </properties>
<scm> <scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection> <connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection> scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>
scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url> <url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
</scm> </scm>
@ -119,29 +183,29 @@
<!-- OPTIONAL. authorization-control-library: add this plugin if you <!-- OPTIONAL. authorization-control-library: add this plugin if you
want to use gcube want to use gcube
authorization control funzionalities --> authorization control funzionalities -->
<!-- <plugin>--> <!-- <plugin>-->
<!-- <groupId>org.codehaus.mojo</groupId>--> <!-- <groupId>org.codehaus.mojo</groupId>-->
<!-- <artifactId>aspectj-maven-plugin</artifactId>--> <!-- <artifactId>aspectj-maven-plugin</artifactId>-->
<!-- <version>${aspectj-plugin.version}</version>--> <!-- <version>${aspectj-plugin.version}</version>-->
<!-- <configuration>--> <!-- <configuration>-->
<!-- <complianceLevel>${java.version}</complianceLevel>--> <!-- <complianceLevel>${java.version}</complianceLevel>-->
<!-- <source>${java.version}</source>--> <!-- <source>${java.version}</source>-->
<!-- <target>${java.version}</target>--> <!-- <target>${java.version}</target>-->
<!-- <aspectLibraries>--> <!-- <aspectLibraries>-->
<!-- <aspectLibrary>--> <!-- <aspectLibrary>-->
<!-- <groupId>org.gcube.common</groupId>--> <!-- <groupId>org.gcube.common</groupId>-->
<!-- <artifactId>authorization-control-library</artifactId>--> <!-- <artifactId>authorization-control-library</artifactId>-->
<!-- </aspectLibrary>--> <!-- </aspectLibrary>-->
<!-- </aspectLibraries>--> <!-- </aspectLibraries>-->
<!-- </configuration>--> <!-- </configuration>-->
<!-- <executions>--> <!-- <executions>-->
<!-- <execution>--> <!-- <execution>-->
<!-- <goals>--> <!-- <goals>-->
<!-- <goal>compile</goal>--> <!-- <goal>compile</goal>-->
<!-- </goals>--> <!-- </goals>-->
<!-- </execution>--> <!-- </execution>-->
<!-- </executions>--> <!-- </executions>-->
<!-- </plugin>--> <!-- </plugin>-->
<!-- Sphinx plugin' --> <!-- Sphinx plugin' -->
@ -150,12 +214,14 @@
<artifactId>sphinx-maven-plugin</artifactId> <artifactId>sphinx-maven-plugin</artifactId>
<version>2.10.0</version> <version>2.10.0</version>
<configuration> <configuration>
<outputDirectory>${project.build.directory}/${project.build.finalName}/docs</outputDirectory> <outputDirectory>
${project.build.directory}${file.separator}${project.build.finalName}${file.separator}docs</outputDirectory>
<builder>html</builder> <builder>html</builder>
<configDirectory>${basedir}/sphinx</configDirectory> <configDirectory>${project.basedir}${file.separator}documentation${file.separator}sphinx</configDirectory>
<sourceDirectory>${basedir}/sphinx</sourceDirectory> <sourceDirectory>${project.basedir}${file.separator}documentation${file.separator}sphinx</sourceDirectory>
<!-- brew install sphinx-doc --> <!-- brew install sphinx-doc -->
<binaryUrl>file:/opt/homebrew/opt/sphinx-doc/bin/sphinx-build</binaryUrl> <binaryUrl>
file:/opt/homebrew/opt/sphinx-doc/bin/sphinx-build</binaryUrl>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
@ -180,34 +246,35 @@
</goals> </goals>
</execution> </execution>
</executions> </executions>
<configuration>
<!-- <docsDir>${project.build.directory}${file.separator}${project.artifactId}-${project.version}${file.separator}api-docs</docsDir>-->
<configFile>${project.basedir}${file.separator}documentation${file.separator}enunciate.xml</configFile>
</configuration>
</plugin> </plugin>
<!-- Copy Enunciate Documentation from your-application/api-docs <!-- Copy Enunciate Documentation from your-application/api-docs into your war -->
into your war -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>copy-enunciate-docs</id> <id>copy-enunciate-docs</id>
<phase>process-resources</phase> <phase>process-resources</phase>
<goals> <goals>
<goal>copy-resources</goal> <goal>copy-resources</goal>
</goals> </goals>
<configuration> <configuration>
<outputDirectory>target</outputDirectory> <outputDirectory>target</outputDirectory>
<resources> <resources>
<resource> <resource>
<targetPath> <targetPath>${project.build.directory}${file.separator}${project.artifactId}-${project.version}${file.separator}api-docs</targetPath>
${project.build.directory}/${project.artifactId}-${project.version}/api-docs</targetPath> <directory>${project.build.directory}/api-docs</directory>
<directory> <filtering>true</filtering>
${project.build.directory}/api-docs</directory> </resource>
<filtering>true</filtering> </resources>
</resource> </configuration>
</resources> </execution>
</configuration> </executions>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -14,11 +14,19 @@
<param-name>jersey.config.server.provider.packages</param-name> <param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.gcube.service.helloworld.rest</param-value> <param-value>org.gcube.service.helloworld.rest</param-value>
</init-param> </init-param>
<init-param> <!-- <init-param>-->
<param-name>jersey.config.server.provider.packages</param-name> <!-- <param-name>jersey.config.server.provider.packages</param-name>-->
<param-value>org.gcube.service.helloworld.mappers</param-value> <!-- <param-value>org.gcube.service.helloworld.mappers</param-value>-->
</init-param> <!-- </init-param>-->
</servlet> </servlet>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/docs/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/api-docs/*</url-pattern>
</servlet-mapping>
<servlet-mapping> <servlet-mapping>
<servlet-name>helloword</servlet-name> <servlet-name>helloword</servlet-name>
<url-pattern>/*</url-pattern> <url-pattern>/*</url-pattern>