diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 7628c2b..7fbb7e3 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -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. diff --git a/sbin/docker_mk_env b/sbin/docker_mk_env index 2fbb3bd..e581d2b 100755 --- a/sbin/docker_mk_env +++ b/sbin/docker_mk_env @@ -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,39 +35,49 @@ 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 + + # Service variables + + dynvar_export "${varible_prefix}_SERVICE_NAME" "${service_name}" - if [[ "${module_name}" == "-" ]] - then - module_name="${target_name}" - fi # 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 + # Building variables + if [[ "${module_name}" == "-" ]] + then + module_name="${target_name}" + fi + if [[ "${target_name_full}" != "-" ]] then # Build @@ -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}" @@ -95,18 +114,21 @@ function docker_service_add dynvar_export "${varible_prefix}_LOG_POST_EXT" "./var/log/supervisor${log_ext_suffix}" 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 - 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}))" - + 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}))" + 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 dynvar_export "${varible_prefix}_PORT_ADMIN_INT" "${port_admin_int}" @@ -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