- Add service_name to docker_service_add function.

This commit is contained in:
Arnaud G. GIBERT 2024-11-23 10:50:07 +01:00
parent 58f1259e90
commit ce4241ff9e
2 changed files with 44 additions and 24 deletions

View File

@ -4,6 +4,7 @@ Rx3-Docker/Docker Tools V 1.3.0 - A. GIBERT - 2024/11/xx
- Improve docker_service_add function.
- Warning: API break!
- Add DOCKER_TOOLS_DEBUG env variable support.

View File

@ -3,8 +3,13 @@
set -o errexit
if [[ "$DOCKER_TOOLS_DEBUG" == "TRUE" ]]
then
set -x
fi
APPL_HOME_DIR="$(dirname "$(dirname "$0")")"
DYNVAR_LIST=""
DYNVAR_LIST="APPL_HOME_DIR"
version="$1"
@ -30,38 +35,48 @@ function docker_service_add
varible_prefix="$1"
shift
for var in target_url_prefix target_name target_name_full target_version from_url_prefix from_name from_version module_name module_version port_main_ext port_main_int port_admin_ext port_admin_int user_name_id group_name_id
for var in service_name target_url_prefix target_name target_name_full target_version from_url_prefix from_name from_version module_name module_version port_main_ext port_main_int port_admin_ext port_admin_int user_name_id group_name_id
do
eval ${var}=\"${1}\"
shift
done
if [[ "${module_name}" == "-" ]]
then
module_name="${target_name}"
fi
# Service variables
dynvar_export "${varible_prefix}_SERVICE_NAME" "${service_name}"
# Global Image variables
if [[ "${target_name}" == "-" ]]
then
target_name="${service_name}"
fi
dynvar_export "${varible_prefix}_IMG_NAME" "${target_name}"
dynvar_export "${varible_prefix}_IMG_NAME_FULL" "${target_name_full}"
dynvar_export "${varible_prefix}_IMG_VERSION" "${target_version}"
dynvar_export "${varible_prefix}_IMG_MAINTAINER" "\${ORG_MAINTAINER}"
dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}/${target_name}:${target_version}"
if [[ "${HOST_NAME_PREFIX}" == "" ]]
if [[ "${service_name}" == "${APPL_NAME}" ]]
then
prefix=""
dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}:${target_version}"
dynvar_export "${varible_prefix}_HOST_NAME" "${HOST_NAME_PREFIX}-webapp"
else
prefix="${HOST_NAME_PREFIX}-"
dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}/${target_name}:${target_version}"
dynvar_export "${varible_prefix}_HOST_NAME" "${HOST_NAME_PREFIX}-${service_name}"
fi
dynvar_export "${varible_prefix}_HOST_NAME" "${prefix}${target_name}"
# Building variables
# Building
if [[ "${module_name}" == "-" ]]
then
module_name="${target_name}"
fi
if [[ "${target_name_full}" != "-" ]]
then
@ -80,8 +95,12 @@ function docker_service_add
if [[ "${APPL_NAME}" != "" ]]
then
log_ext_suffix="-${target_name}"
dynvar_export "${varible_prefix}_CONTEXT_PATH" "/${APPL_NAME}/${target_name}/"
else
log_ext_suffix=""
dynvar_export "${varible_prefix}_CONTEXT_PATH" "/${target_name}/"
fi
dynvar_export "${varible_prefix}_LIB_INT" "/var/lib/${module_name}"
@ -96,16 +115,19 @@ function docker_service_add
dynvar_export "${varible_prefix}_LOG_MAIN_INT" "/var/log/${module_name}"
dynvar_export "${varible_prefix}_LOG_MAIN_EXT" "./var/log/${module_name}"
dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}/${target_name}:${target_version}"
# Ports
if [[ "${port_main_int}" != "-" ]]
then
dynvar_export "${varible_prefix}_PORT_MAIN_INT" "${port_main_int}"
dynvar_export "${varible_prefix}_PORT_MAIN_EXT" "\$(( ${port_main_ext} + ${PORT_ENV_OFFSET}))"
dynvar_export "${varible_prefix}_PORT_SV_INT" "9001"
dynvar_export "${varible_prefix}_PORT_SV_EXT" "\$(( \${${varible_prefix}_PORT_MAIN_EXT} + ${PORT_SV_OFFSET}))"
fi
if [[ "${PORT_SV_INT}" != "" ]]
then
dynvar_export "${varible_prefix}_PORT_SV_INT" "${PORT_SV_INT}"
dynvar_export "${varible_prefix}_PORT_SV_EXT" "\$(( \${${varible_prefix}_PORT_MAIN_EXT} + ${PORT_SV_OFFSET}))"
fi
if [[ "${port_admin_int}" != "-" ]]
then
@ -152,15 +174,12 @@ function docker_service_add
dynvar_export "${varible_prefix}_GROUP_NAME" "${group_name}"
dynvar_export "${varible_prefix}_GROUP_ID" "${group_id}"
dynvar_export "${varible_prefix}_CONTEXT_PATH" "/${APPL_NAME}/${target_name}/"
}
#-------------------------------------------------------------------------------
function zdocker_service_add
function docker_service_add-12
{
varible_prefix="$1"
shift