support docker compose v2
This commit is contained in:
parent
432ab6f915
commit
3ecb127f33
|
@ -2,6 +2,8 @@
|
||||||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
source "$(dirname -- "$0")/lib/ulib/auto" || exit 1
|
source "$(dirname -- "$0")/lib/ulib/auto" || exit 1
|
||||||
|
|
||||||
|
[ -n "$COMPOSE_V1" ] && DOCKER_COMPOSE=(docker-compose) || DOCKER_COMPOSE=(docker compose)
|
||||||
|
|
||||||
function display_help() {
|
function display_help() {
|
||||||
uecho "$scriptname: se connecter à la base MySQL
|
uecho "$scriptname: se connecter à la base MySQL
|
||||||
|
|
||||||
|
@ -11,6 +13,8 @@ USAGE
|
||||||
$scriptname -c [-uUSER [-pPASSWORD]] <backup.sql
|
$scriptname -c [-uUSER [-pPASSWORD]] <backup.sql
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
|
--compose-v1
|
||||||
|
Forcer l'utilisation de docker-compose v1
|
||||||
-h, -s, --service SERVICE
|
-h, -s, --service SERVICE
|
||||||
Spécifier le nom du service. La valeur par défaut est db
|
Spécifier le nom du service. La valeur par défaut est db
|
||||||
-i, --ipnum IPNUM
|
-i, --ipnum IPNUM
|
||||||
|
@ -40,6 +44,7 @@ user=
|
||||||
password=
|
password=
|
||||||
args=(
|
args=(
|
||||||
--help '$exit_with display_help'
|
--help '$exit_with display_help'
|
||||||
|
--compose-v1 '$DOCKER_COMPOSE=(docker-compose)'
|
||||||
-h:,-s:,--service: service=
|
-h:,-s:,--service: service=
|
||||||
-i:,--ipnum: ipnum=
|
-i:,--ipnum: ipnum=
|
||||||
-c,--mysql-cmd mysql_cmd=1
|
-c,--mysql-cmd mysql_cmd=1
|
||||||
|
@ -72,7 +77,7 @@ fi
|
||||||
###
|
###
|
||||||
|
|
||||||
function die_not_found() { die "$service: service introuvable. vérifiez que le projet est actuellement up"; }
|
function die_not_found() { die "$service: service introuvable. vérifiez que le projet est actuellement up"; }
|
||||||
setx cid=docker-compose ps -q "$service" 2>/dev/null || die_not_found
|
setx cid="${DOCKER_COMPOSE[@]}" ps -q "$service" 2>/dev/null || die_not_found
|
||||||
[ -n "$cid" ] || die_not_found
|
[ -n "$cid" ] || die_not_found
|
||||||
edebug "$service id: $cid"
|
edebug "$service id: $cid"
|
||||||
|
|
||||||
|
@ -107,7 +112,7 @@ elif [ -n "$klean" ]; then
|
||||||
estep "wait 10sec..."
|
estep "wait 10sec..."
|
||||||
sleep 10
|
sleep 10
|
||||||
estep "start"
|
estep "start"
|
||||||
docker-compose start "$service"
|
"${DOCKER_COMPOSE[@]}" start "$service"
|
||||||
|
|
||||||
else
|
else
|
||||||
[ -f bin/conndev.php ] || die "Impossible de trouver le script compagnon conndev.php"
|
[ -f bin/conndev.php ] || die "Impossible de trouver le script compagnon conndev.php"
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
source "$(dirname -- "$0")/lib/ulib/auto" || exit 1
|
source "$(dirname -- "$0")/lib/ulib/auto" || exit 1
|
||||||
|
|
||||||
|
[ -n "$COMPOSE_V1" ] && DOCKER_COMPOSE=(docker-compose) || DOCKER_COMPOSE=(docker compose)
|
||||||
|
|
||||||
function display_help() {
|
function display_help() {
|
||||||
uecho "$scriptname: ouvrir un shell dans le container
|
uecho "$scriptname: ouvrir un shell dans le container
|
||||||
|
|
||||||
|
@ -9,6 +11,8 @@ USAGE
|
||||||
$scriptname [CMD...]
|
$scriptname [CMD...]
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
|
--compose-v1
|
||||||
|
Forcer l'utilisation de docker-compose v1
|
||||||
-h, -s, --service SERVICE
|
-h, -s, --service SERVICE
|
||||||
Spécifier le nom du service sur lequel ouvrir le shell
|
Spécifier le nom du service sur lequel ouvrir le shell
|
||||||
-d, --db
|
-d, --db
|
||||||
|
@ -20,6 +24,7 @@ OPTIONS
|
||||||
service=web
|
service=web
|
||||||
args=(
|
args=(
|
||||||
--help '$exit_with display_help'
|
--help '$exit_with display_help'
|
||||||
|
--compose-v1 '$DOCKER_COMPOSE=(docker-compose)'
|
||||||
-h:,-s:,--service: service=
|
-h:,-s:,--service: service=
|
||||||
-d,--db service=db
|
-d,--db service=db
|
||||||
-w,--web service=web
|
-w,--web service=web
|
||||||
|
@ -47,9 +52,9 @@ fi
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
setx cid=docker-compose ps -q "$service" 2>/dev/null || die "$service: service introuvable"
|
setx cid="${DOCKER_COMPOSE[@]}" ps -q "$service" 2>/dev/null || die "$service: service introuvable"
|
||||||
|
|
||||||
cmd=("$@")
|
cmd=("$@")
|
||||||
[ ${#cmd[*]} -gt 0 ] || cmd=(bash)
|
[ ${#cmd[*]} -gt 0 ] || cmd=(bash)
|
||||||
|
|
||||||
docker-compose exec "$service" "${cmd[@]}"
|
"${DOCKER_COMPOSE[@]}" exec "$service" "${cmd[@]}"
|
||||||
|
|
44
dk
44
dk
|
@ -1237,7 +1237,7 @@ function default_update_build_env() {
|
||||||
function update_build_env() { default_update_build_env "$@"; }
|
function update_build_env() { default_update_build_env "$@"; }
|
||||||
|
|
||||||
function default_compose_build() {
|
function default_compose_build() {
|
||||||
${FAKE:+qvals} docker-compose \
|
${FAKE:+qvals} "${DOCKER_COMPOSE[@]}" \
|
||||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||||
build \
|
build \
|
||||||
${NO_CACHE:+--no-cache} \
|
${NO_CACHE:+--no-cache} \
|
||||||
|
@ -1307,7 +1307,7 @@ function auto_build() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_compose_push() {
|
function default_compose_push() {
|
||||||
${FAKE:+qvals} docker-compose \
|
${FAKE:+qvals} "${DOCKER_COMPOSE[@]}" \
|
||||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||||
push \
|
push \
|
||||||
"$@"
|
"$@"
|
||||||
|
@ -1345,7 +1345,7 @@ function auto_push() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_compose_up() {
|
function default_compose_up() {
|
||||||
${FAKE:+qvals} docker-compose \
|
${FAKE:+qvals} "${DOCKER_COMPOSE[@]}" \
|
||||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||||
up "${replace_run_args[@]}" "${run_args[@]}" \
|
up "${replace_run_args[@]}" "${run_args[@]}" \
|
||||||
"${replace_user_args[@]}" "${user_args[@]}" "$@"
|
"${replace_user_args[@]}" "${user_args[@]}" "$@"
|
||||||
|
@ -1379,7 +1379,7 @@ function auto_up() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_compose_stop() {
|
function default_compose_stop() {
|
||||||
${FAKE:+qvals} docker-compose \
|
${FAKE:+qvals} "${DOCKER_COMPOSE[@]}" \
|
||||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||||
stop "${replace_stop_args[@]}" "${stop_args[@]}" \
|
stop "${replace_stop_args[@]}" "${stop_args[@]}" \
|
||||||
"$@"
|
"$@"
|
||||||
|
@ -1408,7 +1408,7 @@ function auto_stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_compose_logs() {
|
function default_compose_logs() {
|
||||||
${FAKE:+qvals} docker-compose \
|
${FAKE:+qvals} "${DOCKER_COMPOSE[@]}" \
|
||||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||||
logs "${replace_logs_args[@]}" "${logs_args[@]}" \
|
logs "${replace_logs_args[@]}" "${logs_args[@]}" \
|
||||||
"$@"
|
"$@"
|
||||||
|
@ -1439,7 +1439,7 @@ function auto_logs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_compose_down() {
|
function default_compose_down() {
|
||||||
${FAKE:+qvals} docker-compose \
|
${FAKE:+qvals} "${DOCKER_COMPOSE[@]}" \
|
||||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||||
down "${replace_down_args[@]}" "${down_args[@]}" \
|
down "${replace_down_args[@]}" "${down_args[@]}" \
|
||||||
"$@"
|
"$@"
|
||||||
|
@ -1474,7 +1474,7 @@ function auto_down() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_compose_run() {
|
function default_compose_run() {
|
||||||
${FAKE:+qvals} docker-compose \
|
${FAKE:+qvals} "${DOCKER_COMPOSE[@]}" \
|
||||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||||
run "${replace_run_args[@]}" "${run_args[@]}" \
|
run "${replace_run_args[@]}" "${run_args[@]}" \
|
||||||
"${replace_user_args[@]}" "${user_args[@]}" "$@"
|
"${replace_user_args[@]}" "${user_args[@]}" "$@"
|
||||||
|
@ -1545,7 +1545,7 @@ function auto_run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_compose_exec() {
|
function default_compose_exec() {
|
||||||
${FAKE:+qvals} docker-compose \
|
${FAKE:+qvals} "${DOCKER_COMPOSE[@]}" \
|
||||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||||
exec "${replace_exec_args[@]}" "${exec_args[@]}" \
|
exec "${replace_exec_args[@]}" "${exec_args[@]}" \
|
||||||
"$@"
|
"$@"
|
||||||
|
@ -1759,7 +1759,7 @@ function auto_status() {
|
||||||
function default_compose_show_ip() {
|
function default_compose_show_ip() {
|
||||||
local -a cmd cids; local cid
|
local -a cmd cids; local cid
|
||||||
cmd=(
|
cmd=(
|
||||||
docker-compose
|
"${DOCKER_COMPOSE[@]}"
|
||||||
"${replace_env_args[@]}" "${env_args[@]}"
|
"${replace_env_args[@]}" "${env_args[@]}"
|
||||||
ps -q "${replace_show_ip_args[@]}" "${show_ip_args[@]}"
|
ps -q "${replace_show_ip_args[@]}" "${show_ip_args[@]}"
|
||||||
"$@"
|
"$@"
|
||||||
|
@ -1795,7 +1795,23 @@ function auto_show_ip() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_compose_systemd_unit() {
|
function default_compose_systemd_unit() {
|
||||||
local docker_compose="$(which docker-compose 2>/dev/null)"
|
local -a docker_compose
|
||||||
|
if [ "${DOCKER_COMPOSE[0]}" == docker ]; then
|
||||||
|
# compose v2
|
||||||
|
local docker="$(which docker 2>/dev/null)"
|
||||||
|
if [ -z "$docker" ]; then
|
||||||
|
if [ -x /usr/bin/docker ]; then
|
||||||
|
docker=/usr/bin/docker
|
||||||
|
elif [ -x /usr/local/bin/docker ]; then
|
||||||
|
docker=/usr/local/bin/docker
|
||||||
|
else
|
||||||
|
die "Impossible de trouver docker"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
docker_compose=("$docker" compose)
|
||||||
|
else
|
||||||
|
# compose v1
|
||||||
|
docker_compose="$(which docker-compose 2>/dev/null)"
|
||||||
if [ -z "$docker_compose" ]; then
|
if [ -z "$docker_compose" ]; then
|
||||||
if [ -x /usr/bin/docker-compose ]; then
|
if [ -x /usr/bin/docker-compose ]; then
|
||||||
docker_compose=/usr/bin/docker-compose
|
docker_compose=/usr/bin/docker-compose
|
||||||
|
@ -1805,11 +1821,12 @@ function default_compose_systemd_unit() {
|
||||||
die "Impossible de trouver docker-compose"
|
die "Impossible de trouver docker-compose"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
setx startcmd=qvals "$docker_compose" \
|
fi
|
||||||
|
setx startcmd=qvals "${docker_compose[@]}" \
|
||||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||||
up "${replace_run_args[@]}" "${run_args[@]}" \
|
up "${replace_run_args[@]}" "${run_args[@]}" \
|
||||||
"${replace_user_args[@]}" "${user_args[@]}" "$@"
|
"${replace_user_args[@]}" "${user_args[@]}" "$@"
|
||||||
setx stopcmd=qvals "$docker_compose" down
|
setx stopcmd=qvals "${docker_compose[@]}" down
|
||||||
}
|
}
|
||||||
function default_docker_systemd_unit() {
|
function default_docker_systemd_unit() {
|
||||||
local docker="$(which "$DOCKER" 2>/dev/null)"
|
local docker="$(which "$DOCKER" 2>/dev/null)"
|
||||||
|
@ -2390,6 +2407,8 @@ elif progexists podman; then DOCKER=podman
|
||||||
else DOCKER=docker
|
else DOCKER=docker
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[ -n "$COMPOSE_V1" ] && DOCKER_COMPOSE=(docker-compose) || DOCKER_COMPOSE=(docker compose)
|
||||||
|
|
||||||
DEFAULT_PROFILE=devel
|
DEFAULT_PROFILE=devel
|
||||||
PROFILE=
|
PROFILE=
|
||||||
DM_ALIASES=()
|
DM_ALIASES=()
|
||||||
|
@ -2431,6 +2450,7 @@ update_apps_origin=
|
||||||
update_apps_branch=
|
update_apps_branch=
|
||||||
args=(
|
args=(
|
||||||
--help '$exit_with display_help'
|
--help '$exit_with display_help'
|
||||||
|
--compose-v1 '$DOCKER_COMPOSE=(docker-compose)'
|
||||||
-d:,--chdir: chdir=
|
-d:,--chdir: chdir=
|
||||||
-c:,--config: CONFIG=
|
-c:,--config: CONFIG=
|
||||||
-p:,--profile: PROFILE=
|
-p:,--profile: PROFILE=
|
||||||
|
|
8
dkbuild
8
dkbuild
|
@ -6,6 +6,8 @@ urequire ptools xmlsupport
|
||||||
SELF="$script"
|
SELF="$script"
|
||||||
TEMPLATEDIR="$scriptdir/lib/dkbuild/templates"
|
TEMPLATEDIR="$scriptdir/lib/dkbuild/templates"
|
||||||
|
|
||||||
|
[ -n "$COMPOSE_V1" ] && DOCKER_COMPOSE=(docker-compose) || DOCKER_COMPOSE=(docker compose)
|
||||||
|
|
||||||
function get_default_phpbuilder_image() {
|
function get_default_phpbuilder_image() {
|
||||||
echo "${REGISTRY:-docker.univ-reunion.fr}/image/phpbuilder:${DIST:-d11}"
|
echo "${REGISTRY:-docker.univ-reunion.fr}/image/phpbuilder:${DIST:-d11}"
|
||||||
}
|
}
|
||||||
|
@ -28,6 +30,8 @@ OPTIONS
|
||||||
--href, --help-reference
|
--href, --help-reference
|
||||||
Afficher la référence sur les commandes utilisables dans un fichier
|
Afficher la référence sur les commandes utilisables dans un fichier
|
||||||
dkbuild
|
dkbuild
|
||||||
|
--compose-v1
|
||||||
|
Forcer l'utilisation de docker-compose v1
|
||||||
|
|
||||||
ACTIONS
|
ACTIONS
|
||||||
|
|
||||||
|
@ -2070,7 +2074,7 @@ function define_functions_cmd() {
|
||||||
echo_setv "$evar=${ENVIRON[$evar]}" >>.env
|
echo_setv "$evar=${ENVIRON[$evar]}" >>.env
|
||||||
done
|
done
|
||||||
|
|
||||||
_runcmd docker-compose "${args[@]}" build "${bargs[@]}" "$@" || die
|
_runcmd "${DOCKER_COMPOSE[@]}" "${args[@]}" build "${bargs[@]}" "$@" || die
|
||||||
}
|
}
|
||||||
function _local_composer() {
|
function _local_composer() {
|
||||||
case "$action" in
|
case "$action" in
|
||||||
|
@ -3011,6 +3015,7 @@ while [ $# -gt 0 ]; do
|
||||||
--help) args+=("$1"); shift; continue;;
|
--help) args+=("$1"); shift; continue;;
|
||||||
--hdk|--help-dkbuild) args+=("$1"); shift; continue;;
|
--hdk|--help-dkbuild) args+=("$1"); shift; continue;;
|
||||||
--href|--help-reference) args+=("$1"); shift; continue;;
|
--href|--help-reference) args+=("$1"); shift; continue;;
|
||||||
|
--compose-v1) args+=("$1"); shift; continue;;
|
||||||
-*|*=*) # option quelconque: inférer build
|
-*|*=*) # option quelconque: inférer build
|
||||||
args+=(build)
|
args+=(build)
|
||||||
break
|
break
|
||||||
|
@ -3026,6 +3031,7 @@ args=(+
|
||||||
--help '$exit_with display_help'
|
--help '$exit_with display_help'
|
||||||
--hdk,--help-dkbuild '$exit_with display_help_dkbuild'
|
--hdk,--help-dkbuild '$exit_with display_help_dkbuild'
|
||||||
--href,--help-reference '$exit_with display_help_reference'
|
--href,--help-reference '$exit_with display_help_reference'
|
||||||
|
--compose-v1 '$DOCKER_COMPOSE=(docker-compose)'
|
||||||
)
|
)
|
||||||
parse_args "$@"; set -- "${args[@]}"
|
parse_args "$@"; set -- "${args[@]}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue