config docker e builder
This commit is contained in:
parent
60e5bba5a4
commit
57584a0a26
22
Dockerfile
22
Dockerfile
|
@ -1,14 +1,28 @@
|
|||
ARG JAVA_VERSION=11
|
||||
ARG SMARTGEARS_VERSION=4.0.1-SNAPSHOT
|
||||
# docker build -t $DOCKER_BUILD_NAME \
|
||||
# --build-arg="MVN_FINALNAME=$MVN_FINALNAME" \
|
||||
# --build-arg="MVN_NAME=${MVN_NAME}" \
|
||||
# --build-arg="CONTAINER_INI=${CONTAINER_INI}" \
|
||||
# --build-arg="JAVA_VERSION=${JAVA_VERSION}" \
|
||||
# --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" \
|
||||
# $PLATFORMS .
|
||||
|
||||
ARG JAVA_VERSION
|
||||
ARG SMARTGEARS_VERSION
|
||||
|
||||
#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 smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19
|
||||
ARG CONTAINER_INI="./docker/container.ini"
|
||||
ARG MVN_FINALNAME
|
||||
ARG MVN_NAME
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install unzip
|
||||
#FROM smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19
|
||||
|
||||
COPY ./docker/logback.xml /etc/
|
||||
COPY ./docker/*.gcubekey /tomcat/lib
|
||||
COPY ./target/helloworld.war /tomcat/webapps/
|
||||
COPY ./target/${MVN_FINALNAME}.war /tmp
|
||||
RUN unzip /tmp/${MVN_FINALNAME}.war -d /tomcat/webapps/${MVN_NAME}
|
||||
COPY ${CONTAINER_INI} /etc/container.ini
|
||||
|
||||
EXPOSE 8080
|
||||
|
|
|
@ -65,9 +65,9 @@ connect the JAVA debugger to port 5005
|
|||
# maven configuration for the project
|
||||
├── pom.xml
|
||||
│
|
||||
# the files in the gcube folder are processed by mvn parent and
|
||||
# the variables ${VAR} resolved using the values found in pom.xml
|
||||
# and the generated file
|
||||
# the files in the gcube folder are processed by mvn parent during the packing fase
|
||||
# the variables ${VAR} are resolved using the values found in pom.xml
|
||||
# and the generated file are copied (respecting the gcube folder structure) inside the folder generated in ./target and so in the corrisponding war file
|
||||
├── gcube
|
||||
│ └── extra-resources
|
||||
│ └── WEB-INF
|
||||
|
@ -120,6 +120,7 @@ connect the JAVA debugger to port 5005
|
|||
│ ├── container.ini -> container.dev.ini
|
||||
│ ├── devsec.gcubekey
|
||||
│ └── logback.xml
|
||||
├── build_conf
|
||||
├── buildImageAndStart.sh
|
||||
├── Dockerfile
|
||||
│
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
# set -x # uncomment to debug script
|
||||
|
||||
BUILD_VERSION=0.0.1-SNAPSHOT
|
||||
SMARTGEARS_VERSION=4.0.1-SNAPSHOT
|
||||
set -a
|
||||
. ./build_conf
|
||||
set +a
|
||||
|
||||
ACCEPTED_JAVA_VERSIONs=(11 17)
|
||||
PORT=8080
|
||||
|
@ -13,24 +13,10 @@ EXECUTE=false
|
|||
TEST=false
|
||||
COMPILE=true
|
||||
|
||||
JAVA_VERSION=11
|
||||
NAME=helloword
|
||||
CONTAINER_INI="./docker/container.ini"
|
||||
IMAGE_VERSION=${BUILD_VERSION}-java${JAVA_VERSION}-smartgears${SMARTGEARS_VERSION}
|
||||
|
||||
PUSH_DOCKER=false
|
||||
PUSH_HARBOR=false
|
||||
LOGIN_HARBOR=false
|
||||
|
||||
BUILD_NAME=$NAME:$IMAGE_VERSION
|
||||
|
||||
SMARTGEAR_IMAGE=hub.dev.d4science.org/gcube/smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-tomcat10.1.19
|
||||
DOCKER_IMAGE_NAME=d4science/$BUILD_NAME
|
||||
HARBOR_IMAGE_NAME=hub.dev.d4science.org/gcube/$BUILD_NAME
|
||||
|
||||
|
||||
echo "BUILD_NAME=$BUILD_NAME"
|
||||
|
||||
################################################################################
|
||||
# Help #
|
||||
################################################################################
|
||||
|
@ -38,21 +24,29 @@ Help() {
|
|||
# Display Help
|
||||
echo "build, create and run in docker the identity manager service"
|
||||
echo
|
||||
echo "Syntax: buildDistribution [-n arg] [-p arg] [-j arg] [-d arg?] [-h]"
|
||||
echo "Syntax: buildDistribution "
|
||||
echo "options:"
|
||||
echo "-s skip maven package"
|
||||
echo "-t exec also maven tests"
|
||||
echo "-n arg specifies the docker image name (default is identity-manager)."
|
||||
|
||||
echo "-e execute the docker image"
|
||||
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 "-u p[u]sh image to dockerhub (with docker login already done)"
|
||||
|
||||
echo "-p arg specifies the port to be exposed for the docker container to access the service (default $PORT)"
|
||||
|
||||
echo "-c arg path of the file to deploy as container.ini (default ./docker/container.ini)"
|
||||
|
||||
echo "-j arg specify java version (default is $JAVA_VERSION)"
|
||||
echo " accepted version are: ${ACCEPTED_JAVA_VERSIONs[@]}"
|
||||
echo "-e execute the image"
|
||||
echo "-d arg? enable java debug mode for execution"
|
||||
echo " arg is the debug port (default is $DEBUG_PORT)"
|
||||
echo "-r push image to d4science harbo[r] (with login already done, or -l to login)"
|
||||
|
||||
echo "-s skip maven package"
|
||||
echo "-t exec also maven tests"
|
||||
|
||||
echo "-n arg specifies the docker image name (default is $MVN_NAME)."
|
||||
|
||||
echo "-l [l]ogin to d4science harbor"
|
||||
echo "-u p[u]sh image to dockerhub (with docker login already done)"
|
||||
echo "-c arg path of the file to deploy as container.ini (default ./docker/container.ini)"
|
||||
echo "-h Print this Help."
|
||||
echo
|
||||
echo "to compile and push to harbor registry with a custom container.ini file: "
|
||||
|
@ -134,25 +128,25 @@ else
|
|||
echo "skipping mvn package"
|
||||
fi
|
||||
|
||||
echo "SMARTGEAR IMAGE: $SMARTGEAR_IMAGE"
|
||||
docker pull $SMARTGEAR_IMAGE
|
||||
|
||||
if [ $MULTI_PLATFORM ]; then
|
||||
|
||||
echo "build multiplatform"
|
||||
|
||||
docker build -t $BUILD_NAME --build-arg="CONTAINER_INI=$CONTAINER_INI" --build-arg="JAVA_VERSION=${JAVA_VERSION}" --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" --platform=linux/amd64,linux/arm64,linux/arm/v7 .
|
||||
else
|
||||
echo "build single platform"
|
||||
docker build -t $BUILD_NAME --build-arg="CONTAINER_INI=$CONTAINER_INI" --build-arg="JAVA_VERSION=${JAVA_VERSION}" --build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" .
|
||||
|
||||
# docker manifest create hub.dev.d4science.org/gcube/$BUILD_NAME \
|
||||
# hub.dev.d4science.org/gcube/$NAME-amd64-linux:$IMAGE_VERSION \
|
||||
# hub.dev.d4science.org/gcube/$NAME-arm-linux:$IMAGE_VERSION \
|
||||
# hub.dev.d4science.org/gcube/$NAME-arm-linux:$IMAGE_VERSION
|
||||
PLATFORMS="--platform=linux/amd64,linux/arm64,linux/arm/v7"
|
||||
echo "build multiple platform $PLATFORMS"
|
||||
fi
|
||||
|
||||
echo "DOCKER_BUILD_NAME: $DOCKER_BUILD_NAME"
|
||||
docker build -t $DOCKER_BUILD_NAME \
|
||||
--build-arg="MVN_FINALNAME=$MVN_FINALNAME" \
|
||||
--build-arg="MVN_NAME=${MVN_NAME}" \
|
||||
--build-arg="CONTAINER_INI=${CONTAINER_INI}" \
|
||||
--build-arg="JAVA_VERSION=${JAVA_VERSION}" \
|
||||
--build-arg="SMARTGEARS_VERSION=${SMARTGEARS_VERSION}" \
|
||||
$PLATFORMS .
|
||||
|
||||
if [ ${PUSH_DOCKER} = true ]; then
|
||||
docker tag $BUILD_NAME $DOCKER_IMAGE_NAME
|
||||
docker tag $DOCKER_BUILD_NAME $DOCKER_IMAGE_NAME
|
||||
docker push $DOCKER_IMAGE_NAME
|
||||
echo ">>> pushed on dockerhub the image $DOCKER_IMAGE_NAME"
|
||||
fi
|
||||
|
@ -164,7 +158,7 @@ fi
|
|||
if [ $PUSH_HARBOR = true ]; then
|
||||
echo ">>> PUSHING on hub.dev.d4science.org the image $HARBOR_IMAGE_NAME"
|
||||
|
||||
docker tag $BUILD_NAME $HARBOR_IMAGE_NAME
|
||||
docker tag $DOCKER_BUILD_NAME $HARBOR_IMAGE_NAME
|
||||
echo ">>> docker push $HARBOR_IMAGE_NAME"
|
||||
docker push $HARBOR_IMAGE_NAME
|
||||
echo ">>> pushed on hub.dev.d4science.org the image $HARBOR_IMAGE_NAME"
|
||||
|
@ -172,8 +166,8 @@ fi
|
|||
|
||||
if [ ${EXECUTE} = true ]; then
|
||||
if [ $DEBUG = true ]; then
|
||||
docker run -p $PORT:8080 -p $DEBUG_PORT:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=y" $BUILD_NAME
|
||||
docker run -p $PORT:8080 -p $DEBUG_PORT:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=y" $DOCKER_BUILD_NAME
|
||||
else
|
||||
docker run -p $PORT:8080 $BUILD_NAME
|
||||
docker run -p $PORT:8080 $DOCKER_BUILD_NAME
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
MVN_VERSION=$(mvn -q \
|
||||
-Dexec.executable=echo \
|
||||
-Dexec.args='${project.version}' \
|
||||
--non-recursive \
|
||||
exec:exec)
|
||||
|
||||
|
||||
MVN_NAME=$(mvn -q \
|
||||
-Dexec.executable=echo \
|
||||
-Dexec.args='${project.artifactId}' \
|
||||
--non-recursive \
|
||||
exec:exec)
|
||||
|
||||
MVN_FINALNAME=$(mvn -q \
|
||||
-Dexec.executable=echo \
|
||||
-Dexec.args='${project.build.finalName}' \
|
||||
--non-recursive \
|
||||
exec:exec)
|
||||
|
||||
JAVA_VERSION=$(mvn -q \
|
||||
-Dexec.executable=echo \
|
||||
-Dexec.args='${maven.compiler.target}' \
|
||||
--non-recursive \
|
||||
exec:exec)
|
||||
|
||||
TOMCAT_VERSION=tomcat10.1.19
|
||||
SMARTGEARS_VERSION=$(mvn -q \
|
||||
-Dexec.executable=echo \
|
||||
-Dexec.args='${docker.smartgear.version}' \
|
||||
--non-recursive \
|
||||
exec:exec)
|
||||
|
||||
CONTAINER_INI="./docker/container.ini"
|
||||
|
||||
IMAGE_VERSION=${MVN_VERSION}-java${JAVA_VERSION}-smartgears${SMARTGEARS_VERSION}
|
||||
DOCKER_BUILD_NAME=$MVN_NAME:$IMAGE_VERSION
|
||||
|
||||
SMARTGEAR_IMAGE=hub.dev.d4science.org/gcube/smartgears-distribution:${SMARTGEARS_VERSION}-java${JAVA_VERSION}-${TOMCAT_VERSION}
|
||||
|
||||
DOCKER_IMAGE_NAME=d4science/$DOCKER_BUILD_NAME
|
||||
HARBOR_IMAGE_NAME=hub.dev.d4science.org/gcube/$DOCKER_BUILD_NAME
|
|
@ -1 +0,0 @@
|
|||
container.alf.ini
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
REGISTRY_URL="hub.dev.d4science.org"
|
||||
#USERNAME="alfredo.oliviero"
|
||||
echo "to obtain Harbor username and CLI secret:"
|
||||
echo "https://hub.dev.d4science.org/ -> user profile -> CLI secret"
|
||||
|
||||
read -p "username:" USERNAME
|
||||
|
||||
echo ""
|
||||
|
||||
read -s -p "CLI secret:" ACCESS_TOKEN
|
||||
echo "$ACCESS_TOKEN" | docker login $REGISTRY_URL -u $USERNAME --password-stdin
|
||||
unset ACCESS_TOKEN
|
14
pom.xml
14
pom.xml
|
@ -9,7 +9,6 @@
|
|||
<name>Smartgears HelloWorld Service</name>
|
||||
<packaging>war</packaging>
|
||||
|
||||
|
||||
<parent>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
|
@ -18,14 +17,17 @@
|
|||
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
|
||||
<!-- OPTIONAL. for authorization-control-library -->
|
||||
<aspectj-plugin.version>1.14.0</aspectj-plugin.version>
|
||||
|
||||
|
||||
<enunciate.version>2.16.1</enunciate.version>
|
||||
|
||||
<docker.smartgear.version>4.0.1-SNAPSHOT</docker.smartgear.version>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
|
@ -47,8 +49,6 @@
|
|||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
|
||||
<!-- smartgears -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
|
@ -73,7 +73,6 @@
|
|||
<artifactId>jersey-container-servlet</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--
|
||||
https://mvnrepository.com/artifact/org.glassfish.jersey.inject/jersey-cdi2-se -->
|
||||
<dependency>
|
||||
|
@ -102,7 +101,6 @@
|
|||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
|
||||
<!-- OPTIONAL generate the war in a different folder, that will be
|
||||
|
@ -152,10 +150,12 @@
|
|||
<artifactId>sphinx-maven-plugin</artifactId>
|
||||
<version>2.10.0</version>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/docs</outputDirectory>
|
||||
<outputDirectory>${project.build.directory}/${project.build.finalName}/docs</outputDirectory>
|
||||
<builder>html</builder>
|
||||
<configDirectory>${basedir}/sphinx</configDirectory>
|
||||
<sourceDirectory>${basedir}/sphinx</sourceDirectory>
|
||||
<!-- brew install sphinx-doc -->
|
||||
<binaryUrl>file:/opt/homebrew/opt/sphinx-doc/bin/sphinx-build</binaryUrl>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
|
Loading…
Reference in New Issue