dk: simplifier la gestion du nommage des services
This commit is contained in:
parent
50dee34e6f
commit
ccbfff4366
28
dk
28
dk
|
@ -147,6 +147,7 @@ function docker_set_run_args() {
|
|||
}
|
||||
function docker_check_name() {
|
||||
[ -n "$NAME" ] || die "Vous devez définir NAME dans .build.env"
|
||||
|
||||
if [ "$1" == set_container_name ]; then
|
||||
project_name="$NAME"
|
||||
container_name="${project_name//[^a-zA-Z0-9_-]/}"
|
||||
|
@ -159,28 +160,27 @@ function compose_set_env_args() {
|
|||
if [ -f docker-compose.override.yml ]; then
|
||||
replace_env_args+=(-f docker-compose.override.yml)
|
||||
fi
|
||||
local PROJECT_NAME=--none--
|
||||
|
||||
local PROJECT_NAME= PROJECT_NAME_REMOVE_SUFFIX=.service PROJECT_NAME_ADD_PROFILE=1
|
||||
[ -f .compose.env ] && source ./.compose.env
|
||||
|
||||
[ -n "$PROJECT_NAME" ] || PROJECT_NAME="$(basename -- "$(pwd)")"
|
||||
PROJECT_NAME="${PROJECT_NAME%$PROJECT_NAME_REMOVE_SUFFIX}"
|
||||
|
||||
if [ -n "$PROFILE" ]; then
|
||||
if [ -f "docker-compose.$PROFILE.yml" ]; then
|
||||
replace_env_args+=(-f "docker-compose.$PROFILE.yml")
|
||||
fi
|
||||
if [ "$PROJECT_NAME" != --none-- ]; then
|
||||
if [ -z "$COMPOSE_PROJECT_NAME" ]; then
|
||||
[ -n "$PROJECT_NAME" ] || PROJECT_NAME="$(basename -- "$(pwd)")"
|
||||
COMPOSE_PROJECT_NAME="${PROJECT_NAME}_${PROFILE}"
|
||||
fi
|
||||
export COMPOSE_PROJECT_NAME
|
||||
fi
|
||||
[ -n "$COMPOSE_PROJECT_NAME" ] || COMPOSE_PROJECT_NAME="$PROJECT_NAME${PROJECT_NAME_ADD_PROFILE:+_${PROFILE}}"
|
||||
else
|
||||
[ -n "$COMPOSE_PROJECT_NAME" ] || COMPOSE_PROJECT_NAME="$PROJECT_NAME"
|
||||
fi
|
||||
export COMPOSE_PROJECT_NAME
|
||||
|
||||
if [ "$1" == set_container_name ]; then
|
||||
if [ "$PROJECT_NAME" == --none-- ]; then
|
||||
project_name="$(basename -- "$(pwd)")"
|
||||
else
|
||||
project_name="$PROJECT_NAME"
|
||||
fi
|
||||
project_name="$PROJECT_NAME"
|
||||
container_name="${project_name//[^a-zA-Z0-9_-]/}"
|
||||
[ -n "$PROFILE" ] && container_name="${container_name}_$PROFILE"
|
||||
[ -n "$PROFILE" -a -n "$PROJECT_NAME_ADD_PROFILE" ] && container_name="${container_name}_$PROFILE"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue