scripts dockerize

This commit is contained in:
Alfredo Oliviero 2024-05-27 16:04:24 +02:00
parent 9eac72e0f5
commit 4df7bfa51e
4 changed files with 36 additions and 21 deletions

View File

@ -7,11 +7,15 @@
# -f Dockerfile \
# $PLATFORMS .
ARG JAVA_VERSION
ARG SMARTGEARS_VERSION
# ARG JAVA_VERSION
# ARG SMARTGEARS_VERSION
# ARG TOMCAT_VERSION
ARG SMARTGEAR_IMAGE
#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}-tomcat{TOMCAT_VERSION}
FROM ${SMARTGEAR_IMAGE}
ARG CONTAINER_INI="./dockerize/configuration/container.ini"
ARG MVN_FINALNAME
ARG MVN_NAME

View File

@ -32,6 +32,7 @@ Help() {
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 " 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 "-u p[u]sh image to dockerhub (with docker login already done)"
@ -40,11 +41,10 @@ Help() {
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 " arg is the debug port (default is $DEBUG_PORT)"
# echo "-j arg specify java version (default is $JAVA_VERSION)"
# echo " accepted version are: ${ACCEPTED_JAVA_VERSIONs[@]}"
echo "-s skip maven package"
echo "-s skip maven execution"
echo "-t exec also maven tests"
echo "-n arg specifies the docker image name (default is $MVN_NAME)."
@ -67,8 +67,8 @@ Help() {
set -e
#OPTSTRING=":sn:p:d:j:?h"
OPTSTRING=":c:n:p:g:d:?jsmulrteh"
#OPTSTRING=":c:n:p:g:d:?jsmulrteh"
OPTSTRING=":c:n:p:g:d:?smulrteh"
while getopts $OPTSTRING opt; do
# echo "Option -${opt} was triggered, Argument: ${OPTARG}"
@ -94,13 +94,13 @@ while getopts $OPTSTRING opt; do
DEBUG_PORT=${OPTARG}
echo "debug enabled, port $DEBUG_PORT, execute $EXECUTE"
;;
j)
if [[ ${ACCEPTED_JAVA_VERSIONs[@]} =~ ${OPTARG} ]]; then
JAVA_VERSION=${OPTARG}
else
echo "Invalid java version" && echo "accepted version are: ${ACCEPTED_JAVA_VERSIONs[@]}" && exit 1
fi
;;
# j)
# if [[ ${ACCEPTED_JAVA_VERSIONs[@]} =~ ${OPTARG} ]]; then
# JAVA_VERSION=${OPTARG}
# else
# echo "Invalid java version" && echo "accepted version are: ${ACCEPTED_JAVA_VERSIONs[@]}" && exit 1
# fi
# ;;
h) Help && exit 0 ;;
:)
@ -147,8 +147,7 @@ echo "DOCKER_BUILD_NAME: $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}" \
--build-arg="SMARTGEAR_IMAGE=${SMARTGEAR_IMAGE}" \
-f Dockerfile \
$PLATFORMS . );

View File

@ -26,7 +26,7 @@ JAVA_VERSION=$(cd .. && mvn -q \
exec:exec)
echo "JAVA_VERSION: ${JAVA_VERSION}"
TOMCAT_VERSION=tomcat10.1.19
TOMCAT_VERSION=10.1.19
echo "TOMCAT_VERSION: ${TOMCAT_VERSION}"
SMARTGEARS_VERSION=$(cd .. && mvn -q \
@ -45,7 +45,7 @@ echo "IMAGE_VERSION: ${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${TOMCAT_VERSION}
echo "SMARTGEAR_IMAGE: ${SMARTGEAR_IMAGE}"
DOCKER_IMAGE_NAME=d4science/$DOCKER_BUILD_NAME

12
dockerize/push_docker.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
set -a
# source build_conf > docker.conf # generate current conf
# source docker.conf
source build_conf
echo "Docker image $HARBOR_IMAGE_NAME"
docker push $HARBOR_IMAGE_NAME
set +a