Compare commits
4 Commits
docker_too
...
master
Author | SHA1 | Date | |
---|---|---|---|
7bf4bc661a | |||
ce4241ff9e | |||
58f1259e90 | |||
9462b195c5 |
@ -1,8 +1,8 @@
|
||||
Welcome to Docker Tools!
|
||||
Welcome to Rx3-Docker/Docker Tools!
|
||||
|
||||
|
||||
|
||||
This is project aims to give some basic tools to be used by others Rx3 docker packaging projects.
|
||||
This project aims to give some basic tools to be used by other Rx3 docker packaging projects.
|
||||
|
||||
Features:
|
||||
- docker_mk_env command to compile env file into .env file,
|
||||
@ -16,4 +16,4 @@ Your Docker Tools Team.
|
||||
|
||||
--
|
||||
arnaud@rx3.net
|
||||
https://git.rx3.org/gitea/rx3/docker_tools
|
||||
https://git.rx3.org/gitea/rx3-docker/docker_tools
|
||||
|
@ -1,3 +1,24 @@
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
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.
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.2.0 - A. GIBERT - 2024/11/15
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Move repo from Rx3/docker_tools to Rx3-Docker/docker_tools,
|
||||
- docker_service_add:
|
||||
- Add *_LOG_* variable generation,
|
||||
- Add docker_build_push command.
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Docker Tools V 1.1.0 - A. GIBERT - 2024/11/03
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
15
sbin/docker_build_push
Executable file
15
sbin/docker_build_push
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
set -o errexit
|
||||
|
||||
APPL_HOME_DIR="$(dirname "$(dirname "$0")")"
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sbin/docker_mk_env
|
||||
|
||||
docker compose build
|
||||
docker compose push
|
@ -3,13 +3,36 @@
|
||||
|
||||
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"
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
function prefix_add
|
||||
{
|
||||
prefix=$1
|
||||
separator=$2
|
||||
var=$3
|
||||
|
||||
|
||||
if [[ "${prefix}" != "" ]]
|
||||
then
|
||||
echo -n "${prefix}${separator}"
|
||||
fi
|
||||
|
||||
echo "${var}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
function dynvar_export
|
||||
{
|
||||
@ -30,21 +53,184 @@ function docker_service_add
|
||||
varible_prefix="$1"
|
||||
shift
|
||||
|
||||
for var in NAME NAME_FULL URL_PREFIX IMG_NAME VERSION_EXT VERSION_INT PORT_MAIN_EXT PORT_MAIN_INT PORT_ADMIN_EXT PORT_ADMIN_INT USER_NAME GROUP_NAME
|
||||
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}"
|
||||
|
||||
|
||||
|
||||
# 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 [[ "${service_name}" == "${APPL_NAME}" ]]
|
||||
then
|
||||
dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}:${target_version}"
|
||||
dynvar_export "${varible_prefix}_HOST_NAME" "$( prefix_add "${HOST_NAME_PREFIX}" "-" "webapp")"
|
||||
else
|
||||
dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}/${target_name}:${target_version}"
|
||||
dynvar_export "${varible_prefix}_HOST_NAME" "$( prefix_add "${HOST_NAME_PREFIX}" "-" "${service_name}")"
|
||||
fi
|
||||
|
||||
|
||||
# Building variables
|
||||
|
||||
if [[ "${module_name}" == "-" ]]
|
||||
then
|
||||
module_name="${target_name}"
|
||||
fi
|
||||
|
||||
if [[ "${target_name_full}" != "-" ]]
|
||||
then
|
||||
# Build
|
||||
|
||||
dynvar_export "${varible_prefix}_MODULE_NAME" "${module_name}"
|
||||
dynvar_export "${varible_prefix}_MODULE_PATH" "src/${module_name}"
|
||||
dynvar_export "${varible_prefix}_MODULE_VERSION" "${module_version}"
|
||||
|
||||
dynvar_export "${varible_prefix}_IMG_FROM_URL" "${from_url_prefix}/${from_name}:${from_version}"
|
||||
fi
|
||||
|
||||
|
||||
# Volume Directories
|
||||
|
||||
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}"
|
||||
dynvar_export "${varible_prefix}_LIB_EXT" "./var/lib/${module_name}"
|
||||
|
||||
dynvar_export "${varible_prefix}_LOG_INIT_INT" "/var/log/init"
|
||||
dynvar_export "${varible_prefix}_LOG_INIT_EXT" "./var/log/init${log_ext_suffix}"
|
||||
dynvar_export "${varible_prefix}_LOG_SV_INT" "/var/log/supervisor"
|
||||
dynvar_export "${varible_prefix}_LOG_SV_EXT" "./var/log/supervisor${log_ext_suffix}"
|
||||
dynvar_export "${varible_prefix}_LOG_POST_INT" "/var/log/supervisor"
|
||||
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}"
|
||||
|
||||
# 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}))"
|
||||
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}"
|
||||
dynvar_export "${varible_prefix}_PORT_ADMIN_EXT" "\$(( ${port_admin_ext} + ${PORT_ENV_OFFSET}))"
|
||||
fi
|
||||
|
||||
|
||||
# User & Group
|
||||
|
||||
if [[ "${user_name_id}" == "-" ]]
|
||||
then
|
||||
user_name="-"
|
||||
user_id="-"
|
||||
else
|
||||
if [[ "${user_name_id}" =~ ^[0-9]+$ ]]
|
||||
then
|
||||
user_name="-"
|
||||
user_id="${user_name_id}"
|
||||
else
|
||||
user_name="${user_name_id}"
|
||||
user_id="$( id -u "${user_name}")"
|
||||
fi
|
||||
fi
|
||||
|
||||
dynvar_export "${varible_prefix}_USER_NAME" "${user_name}"
|
||||
dynvar_export "${varible_prefix}_USER_ID" "${user_id}"
|
||||
|
||||
|
||||
if [[ "${group_name_id}" == "-" ]]
|
||||
then
|
||||
group_name="-"
|
||||
group_id="-"
|
||||
else
|
||||
if [[ "${group_name_id}" =~ ^[0-9]+$ ]]
|
||||
then
|
||||
group_name="-"
|
||||
group_id="${group_name_id}"
|
||||
else
|
||||
group_name="${group_name_id}"
|
||||
group_id="$( getent group "${group_name}" | cut -d: -f3)"
|
||||
fi
|
||||
fi
|
||||
|
||||
dynvar_export "${varible_prefix}_GROUP_NAME" "${group_name}"
|
||||
dynvar_export "${varible_prefix}_GROUP_ID" "${group_id}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
function docker_service_add-12
|
||||
{
|
||||
varible_prefix="$1"
|
||||
shift
|
||||
|
||||
for var in NAME NAME_FULL URL_PREFIX IMG_NAME APPL_NAME VERSION_EXT VERSION_INT PORT_MAIN_EXT PORT_MAIN_INT PORT_ADMIN_EXT PORT_ADMIN_INT USER_NAME GROUP_NAME
|
||||
do
|
||||
dynvar_export "${varible_prefix}_${var}" "$1"
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
dynvar_export "${varible_prefix}_LOG_INIT_INT" "/var/log/init"
|
||||
dynvar_export "${varible_prefix}_LOG_INIT_EXT" "./var/log/init-\${${varible_prefix}_NAME}"
|
||||
dynvar_export "${varible_prefix}_LOG_SV_INT" "/var/log/supervisor"
|
||||
dynvar_export "${varible_prefix}_LOG_SV_EXT" "./var/log/supervisor-\${${varible_prefix}_NAME}"
|
||||
|
||||
if [[ $( eval echo \${${varible_prefix}_APPL_NAME}) != "-" ]]
|
||||
then
|
||||
dynvar_export "${varible_prefix}_LIB_INT" "/var/lib/\${${varible_prefix}_APPL_NAME}"
|
||||
dynvar_export "${varible_prefix}_LIB_EXT" "./var/lib/\${${varible_prefix}_APPL_NAME}"
|
||||
dynvar_export "${varible_prefix}_LOG_MAIN_INT" "/var/log/\${${varible_prefix}_APPL_NAME}"
|
||||
dynvar_export "${varible_prefix}_LOG_MAIN_EXT" "./var/log/\${${varible_prefix}_APPL_NAME}"
|
||||
fi
|
||||
|
||||
if [[ $( eval echo \${${varible_prefix}_IMG_NAME}) != "-" ]]
|
||||
then
|
||||
# No Build
|
||||
|
||||
dynvar_export "${varible_prefix}_IMG_URL" "\${${varible_prefix}_URL_PREFIX}/\${${varible_prefix}_IMG_NAME}:\${${varible_prefix}_VERSION_INT}"
|
||||
dynvar_export "${varible_prefix}_IMG_URL" "\${${varible_prefix}_URL_PREFIX}/\${${varible_prefix}_IMG_NAME}:\${${varible_prefix}_VERSION_EXT}"
|
||||
else
|
||||
# Build
|
||||
|
||||
dynvar_export "${varible_prefix}_IMG_URL" "\${${varible_prefix}_URL_PREFIX}/\${${varible_prefix}_NAME}:\${${varible_prefix}_VERSION_INT}"
|
||||
dynvar_export "${varible_prefix}_IMG_URL" "\${${varible_prefix}_URL_PREFIX}/\${${varible_prefix}_NAME}:\${${varible_prefix}_VERSION_EXT}"
|
||||
|
||||
dynvar_export "${varible_prefix}_MODULE_NAME" "\${${varible_prefix}_NAME}"
|
||||
dynvar_export "${varible_prefix}_MODULE_PATH" "src/\${${varible_prefix}_NAME}"
|
||||
|
Loading…
Reference in New Issue
Block a user