dk: support ~/.dkbuild.env

This commit is contained in:
Jephté Clain 2024-01-03 19:11:09 +04:00
parent b818e11c73
commit 0bf0f48ad0
3 changed files with 58 additions and 48 deletions

79
dk
View File

@ -2062,7 +2062,16 @@ function auto_composer() {
local COMPOSER_MACHINE=-u
local COMPOSER_CMD=
local COMPOSER_SETUP=
[ -f .composer.conf ] && source ./.composer.conf
if [ -f .composer.yaml ]; then
local registry
eval "$(<.composer.yaml grep ^composer_ |
sed 's/^composer_php_min: /COMPOSER_PHP=/;
s/^composer_php_max: /COMPOSER_PHP_MAX=/;
s/^composer_registry: /registry=/;
s/^composer_image: \(.*\)/COMPOSER_IMAGE="${registry:-$REGISTRY}\/\1"/')"
elif [ -f .composer.conf ]; then
source ./.composer.conf
fi
# les premiers arguments peuvent servir à redéfinir les variables
while [ $# -gt 0 ]; do
case "$1" in
@ -2413,21 +2422,6 @@ fi
[ -n "$COMPOSE_V1" ] && DOCKER_COMPOSE=(docker-compose) || DOCKER_COMPOSE=(docker compose)
DEFAULT_PROFILE=devel
case "$PROFILE" in
jclain)
REGISTRY=docker.jclain.fr
PRIVAREG=docker.jclain.fr
;;
devel)
REGISTRY=docker.devel.self
PRIVAREG=docker.devel.self
;;
prod|test|*)
REGISTRY=pubdocker.univ-reunion.fr
PRIVAREG=pridocker.univ-reunion.fr
;;
esac
PROFILE=
DM_ALIASES=()
DM_PROFILES=()
@ -2435,20 +2429,55 @@ CLUSTERDIRS=()
DEFAULT_DEVEL_SRCDIR="$HOME/wop"
COMPOSER_DEVEL_SRCDIR="$HOME/wop/php"
MAVEN_DEVEL_SRCDIR="$HOME/wop/sn"
DEFAULT_COMPOSER_IMAGE="$REGISTRY/image/phpbuilder:d11"
DEFAULT_MAVEN_IMAGE="$REGISTRY/image/javabuilder:d11"
DEFAULT_COMPOSER_IMAGE=
DEFAULT_MAVEN_IMAGE=
DEFAULT_HOST_MAPPINGS=()
prod_HOST_MAPPINGS=(
pridocker.univ-reunion.fr:10.85.1.56
pubdocker.univ-reunion.fr:10.85.1.57
repos.univ-reunion.fr:10.85.1.57
git.univ-reunion.fr:10.85.1.55
)
test_HOST_MAPPINGS=("${prod_HOST_MAPPINGS[@]}")
set_defaults dk
export PROFILE
DEFAULT_PROFILE=devel
REGISTRY=
HOST_MAPPINGS=()
if [ -f ~/.dkbuild.env ]; then
function default_profile() {
DEFAULT_PROFILE="$1"
}
function profile() {
local profile
for profile in "$@"; do
[ "$profile" == "$DEFAULT_PROFILE" ] && return 0
done
return 1
}
function setenv() {
eval "export $1"
}
function default() {
local command="$1"; shift
local nv n v
case "$command" in
docker)
for nv in "$@"; do
[[ "$nv" == *=* ]] || continue
n="${nv%%=*}"
v="${nv#*=}"
case "$n" in
host-mappings)
read -a nv <<<"$v"
for v in "${ns[@]}"; do
HOST_MAPPINGS+=("$v")
done
;;
esac
done
;;
esac
}
source ~/.dkbuild.env
fi
[ -n "$REGISTRY" ] || REGISTRY=pubdocker.univ-reunion.fr
[ -n "$DEFAULT_COMPOSER_IMAGE" ] || DEFAULT_COMPOSER_IMAGE="$REGISTRY/image/php:d11"
[ -n "$DEFAULT_MAVEN_IMAGE" ] || DEFAULT_MAVEN_IMAGE="$REGISTRY/image/javabuilder:d11"
chdir=
CONFIG=

View File

@ -20,27 +20,5 @@
#MAVEN_DEVEL_SRCDIR="$HOME/wop/sn"
# Image à utiliser pour les builds
#DEFAULT_COMPOSER_IMAGE=pubdocker.univ-reunion.fr/image/phpbuilder:d11
#DEFAULT_COMPOSER_IMAGE=pubdocker.univ-reunion.fr/image/php:d11
#DEFAULT_MAVEN_IMAGE=pubdocker.univ-reunion.fr/image/javabuilder:d11
# Mappings d'hôtes à activer pour les builds à base d'image
#DEFAULT_HOST_MAPPINGS=()
#prod_HOST_MAPPINGS=(pridocker.univ-reunion.fr:10.85.1.56 pubdocker.univ-reunion.fr:10.85.1.57 repos.univ-reunion.fr:10.85.1.57 git.univ-reunion.fr:10.85.1.55)
#test_HOST_MAPPINGS=("${prod_HOST_MAPPINGS}")
#case "$PROFILE" in
#jclain)
# REGISTRY=docker.jclain.fr
# PRIVAREG=docker.jclain.fr
# ;;
#devel)
# REGISTRY=docker.devel.self
# PRIVAREG=docker.devel.self
# ;;
#prod|test|*)
# REGISTRY=pubdocker.univ-reunion.fr
# PRIVAREG=pridocker.univ-reunion.fr
# ;;
#esac
#: ${DEFAULT_COMPOSER_IMAGE:=$REGISTRY/image/phpbuilder:d11}
#: ${DEFAULT_MAVEN_IMAGE:=$REGISTRY/image/javabuilder:d11}

View File

@ -68,6 +68,9 @@ if [ "$UINST_LOCAL_PROFILES" != auto ]; then
export UTOOLS_LOCAL_PROFILES=$(qvalr "$UINST_LOCAL_PROFILES")" ~/.nutoolsrc
fi
# copier .dkbuild.env
[ -f ~/.dkbuild.env ] || cp lib/dkbuild/dot-dkbuild.env ~/.dkbuild.env
# identification du système
echo "##@before *" >lib/profile.d/0nutools
echo_setv UNAME_SYSTEM "$UNAME_SYSTEM" >>lib/profile.d/0nutools