réorganiser le code runphp
This commit is contained in:
parent
682e4048b1
commit
ca8f0a8492
383
runphp/runphp
383
runphp/runphp
@ -117,9 +117,12 @@ function eerror() { eecho "ERROR: $*"; }
|
|||||||
function die() { [ $# -gt 0 ] && eerror "$*"; exit 1; }
|
function die() { [ $# -gt 0 ] && eerror "$*"; exit 1; }
|
||||||
function is_defined() { [ -n "$(declare -p "$1" 2>/dev/null)" ]; }
|
function is_defined() { [ -n "$(declare -p "$1" 2>/dev/null)" ]; }
|
||||||
function in_path() { [ -n "$1" -a -x "$(which "$1" 2>/dev/null)" ]; }
|
function in_path() { [ -n "$1" -a -x "$(which "$1" 2>/dev/null)" ]; }
|
||||||
|
|
||||||
function composer() {
|
function composer() {
|
||||||
cd "$PROJDIR/$COMPOSERDIR" || exit 1
|
if [ -n "$PROJDIR" -a -n "$COMPOSERDIR" ]; then
|
||||||
if [ -n "$COMPOSERPHAR" -a -x "$PROJDIR/$COMPOSERPHAR" ]; then
|
cd "$PROJDIR/$COMPOSERDIR" || exit 1
|
||||||
|
fi
|
||||||
|
if [ -n "$PROJDIR" -a -n "$COMPOSERPHAR" -a -x "$PROJDIR/$COMPOSERPHAR" ]; then
|
||||||
"$PROJDIR/$COMPOSERPHAR" "$@"
|
"$PROJDIR/$COMPOSERPHAR" "$@"
|
||||||
elif in_path composer; then
|
elif in_path composer; then
|
||||||
command composer "$@"
|
command composer "$@"
|
||||||
@ -130,11 +133,40 @@ function composer() {
|
|||||||
else
|
else
|
||||||
die "impossible de trouver composer"
|
die "impossible de trouver composer"
|
||||||
fi
|
fi
|
||||||
if [ -z "$RUNPHP_STANDALONE" -a -f composer.lock ]; then
|
if [ -n "$PROJDIR" -a -z "$RUNPHP_STANDALONE" -a -f composer.lock ]; then
|
||||||
cp composer.lock "$PROJDIR/.composer.lock.runphp"
|
cp composer.lock "$PROJDIR/.composer.lock.runphp"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function ensure_image() {
|
|
||||||
|
function host_parse_args() {
|
||||||
|
# analyser les arguments et calculer les opérations à lancer: bootstrap,
|
||||||
|
# composer install et/ou commande
|
||||||
|
|
||||||
|
# faut-il lancer bootstrap?
|
||||||
|
Bootstrap=auto
|
||||||
|
# faut-il installer les dépendances?
|
||||||
|
Composer=
|
||||||
|
# commande à lancer
|
||||||
|
Cmd=()
|
||||||
|
|
||||||
|
if [ "$1" == --runphp-bootstrap -o "$1" == --bs ]; then
|
||||||
|
Bootstrap=1
|
||||||
|
shift
|
||||||
|
elif [ "$1" == --runphp-exec ]; then
|
||||||
|
Bootstrap=
|
||||||
|
shift
|
||||||
|
elif [ "$1" == --runphp-install -o "$1" == --ci ]; then
|
||||||
|
Composer=ci
|
||||||
|
shift
|
||||||
|
elif [ "$1" == --runphp-update -o "$1" == --cu ]; then
|
||||||
|
Composer=cu
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
Cmd=("$@")
|
||||||
|
}
|
||||||
|
|
||||||
|
function host_ensure_image() {
|
||||||
|
# calculer le nom de l'image runphp
|
||||||
local dfdir suffix dockerfiles dockerfile
|
local dfdir suffix dockerfiles dockerfile
|
||||||
local privareg imagename
|
local privareg imagename
|
||||||
if [ -z "$Image" ]; then
|
if [ -z "$Image" ]; then
|
||||||
@ -161,7 +193,9 @@ function ensure_image() {
|
|||||||
Image="$privareg/$imagename$suffix:$DIST"
|
Image="$privareg/$imagename$suffix:$DIST"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function check_image() {
|
|
||||||
|
function host_check_image() {
|
||||||
|
# vérifier que l'image runphp existe
|
||||||
local image="$Image"
|
local image="$Image"
|
||||||
for prefix in docker.io/library/ docker.io; do
|
for prefix in docker.io/library/ docker.io; do
|
||||||
if [ "${image#$prefix}" != "$image" ]; then
|
if [ "${image#$prefix}" != "$image" ]; then
|
||||||
@ -172,46 +206,25 @@ function check_image() {
|
|||||||
[ -n "$(docker image ls --no-trunc --format '{{.Repository}}:{{.Tag}}' "$image" 2>/dev/null)" ]
|
[ -n "$(docker image ls --no-trunc --format '{{.Repository}}:{{.Tag}}' "$image" 2>/dev/null)" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
## Arguments initiaux
|
function host_check_projdir() {
|
||||||
|
# vérifier le projet pour voir s'il faut installer les dépendances
|
||||||
|
[ -n "$RUNPHP_STANDALONE" ] && return
|
||||||
|
|
||||||
Bootstrap=
|
local install
|
||||||
ComposerInstall=
|
|
||||||
if [ "$1" == --runphp-bootstrap -o "$1" == --bs ]; then
|
|
||||||
Bootstrap=1
|
|
||||||
shift
|
|
||||||
elif [ "$1" == --runphp-exec ]; then
|
|
||||||
Bootstrap=
|
|
||||||
shift
|
|
||||||
elif [ "$1" == --runphp-install -o "$1" == --ci ]; then
|
|
||||||
ComposerInstall=ci
|
|
||||||
shift
|
|
||||||
elif [ "$1" == --runphp-update -o "$1" == --cu ]; then
|
|
||||||
ComposerInstall=cu
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
ForcedBootstrap=
|
|
||||||
if [ -z "$Bootstrap" -a -z "$RUNPHP_STANDALONE" ]; then
|
|
||||||
# si vendor/ n'existe pas, alors on doit faire bootstrap
|
|
||||||
if [ ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
|
if [ ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
|
||||||
ForcedBootstrap=1
|
install=1
|
||||||
elif [ ! -f "$PROJDIR/.composer.lock.runphp" ]; then
|
elif [ ! -f "$PROJDIR/.composer.lock.runphp" ]; then
|
||||||
ForcedBootstrap=1
|
install=1
|
||||||
elif ! diff -q "$PROJDIR/$COMPOSERDIR/composer.lock" "$PROJDIR/.composer.lock.runphp" >&/dev/null; then
|
elif ! diff -q "$PROJDIR/$COMPOSERDIR/composer.lock" "$PROJDIR/.composer.lock.runphp" >&/dev/null; then
|
||||||
ForcedBootstrap=1
|
install=1
|
||||||
fi
|
fi
|
||||||
if [ -n "$ForcedBootstrap" ]; then
|
if [ -n "$install" ]; then
|
||||||
[ "$RUNPHP_MODE" != docker ] && eecho "== bootstrapping runphp"
|
eecho "== bootstrapping runphp"
|
||||||
Bootstrap=1
|
[ -n "$Composer" ] || Composer=ci
|
||||||
ComposerInstall=ci
|
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
|
|
||||||
if [ "$RUNPHP_MODE" != docker ]; then
|
|
||||||
############################################################################
|
|
||||||
# Lancement depuis l'extérieur du container
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
|
function host_init_env() {
|
||||||
## Charger ~/.dkbuild.env
|
## Charger ~/.dkbuild.env
|
||||||
|
|
||||||
APT_PROXY=
|
APT_PROXY=
|
||||||
@ -284,165 +297,142 @@ if [ "$RUNPHP_MODE" != docker ]; then
|
|||||||
UseRslave=1
|
UseRslave=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Toujours vérifier l'existence de l'image
|
|
||||||
Image=
|
Image=
|
||||||
if [ -z "$Bootstrap" ]; then
|
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
|
||||||
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
|
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
|
||||||
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
|
elif [ -n "$BUILDENV" -a -f "$PROJDIR/$BUILDENV" ]; then
|
||||||
for config in "${Configs[@]}"; do
|
Configs=("$PROJDIR/$BUILDENV")
|
||||||
source "$config" || exit 1
|
elif [ -n "$BUILDENV0" -a -f "$PROJDIR/$BUILDENV0" ]; then
|
||||||
done
|
Configs=("$PROJDIR/$BUILDENV0")
|
||||||
after_source_buildenv
|
else
|
||||||
elif [ -n "$BUILDENV" -a -f "$PROJDIR/$BUILDENV" ]; then
|
Configs=()
|
||||||
source "$PROJDIR/$BUILDENV" || exit 1
|
|
||||||
after_source_buildenv
|
|
||||||
elif [ -n "$BUILDENV0" -a -f "$PROJDIR/$BUILDENV0" ]; then
|
|
||||||
source "$PROJDIR/$BUILDENV0" || exit 1
|
|
||||||
after_source_buildenv
|
|
||||||
fi
|
|
||||||
ensure_image
|
|
||||||
if ! check_image; then
|
|
||||||
ForcedBootstrap=1
|
|
||||||
Bootstrap=1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
for config in "${Configs[@]}"; do
|
||||||
|
source "$config" || exit 1
|
||||||
|
done
|
||||||
|
after_source_buildenv
|
||||||
|
|
||||||
Chdir=
|
Chdir=
|
||||||
Verbose="$RUNPHP_VERBOSE"
|
Verbose="$RUNPHP_VERBOSE"
|
||||||
if [ -n "$Bootstrap" ]; then
|
}
|
||||||
## Mode bootstrap de l'image ###########################################
|
|
||||||
# Ici, on a déterminé que l'image doit être construite
|
|
||||||
|
|
||||||
BUILD_ARGS=(
|
function host_docker_build() {
|
||||||
DIST NDIST
|
BUILD_ARGS=(
|
||||||
REGISTRY
|
DIST NDIST
|
||||||
APT_PROXY
|
REGISTRY
|
||||||
APT_MIRROR
|
APT_PROXY
|
||||||
SEC_MIRROR
|
APT_MIRROR
|
||||||
TIMEZONE
|
SEC_MIRROR
|
||||||
)
|
TIMEZONE
|
||||||
|
)
|
||||||
|
|
||||||
SOPTS=+d:9876543210:c:UjDx:z:r:p
|
SOPTS=+d:9876543210:c:UjDx:z:r:p
|
||||||
LOPTS=help,dist:,d19,d18,d17,d16,d15,d14,d13,d12,d11,d10,config:,ue,unless-exists,pull,nc,no-cache,po,plain-output,apt-proxy:,timezone:,privareg:,push,ci,no-use-rslave
|
LOPTS=help,dist:,d19,d18,d17,d16,d15,d14,d13,d12,d11,d10,config:,ue,unless-exists,pull,nc,no-cache,po,plain-output,apt-proxy:,timezone:,privareg:,push,ci,no-use-rslave
|
||||||
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
|
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
|
||||||
|
|
||||||
Dist=
|
Dist=
|
||||||
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
|
UnlessExists=
|
||||||
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
|
Pull=
|
||||||
elif [ -n "$BUILDENV" -a -f "$PROJDIR/$BUILDENV" ]; then
|
NoCache=
|
||||||
Configs=("$PROJDIR/$BUILDENV")
|
PlainOutput=
|
||||||
elif [ -n "$BUILDENV0" -a -f "$PROJDIR/$BUILDENV0" ]; then
|
while [ $# -gt 0 ]; do
|
||||||
Configs=("$PROJDIR/$BUILDENV0")
|
case "$1" in
|
||||||
else
|
--) shift; break;;
|
||||||
Configs=()
|
--help)
|
||||||
fi
|
eecho "\
|
||||||
UnlessExists=
|
|
||||||
Pull=
|
|
||||||
NoCache=
|
|
||||||
PlainOutput=
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case "$1" in
|
|
||||||
--) shift; break;;
|
|
||||||
--help)
|
|
||||||
eecho "\
|
|
||||||
runphp: construire l'image docker
|
runphp: construire l'image docker
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
$MYNAME --runphp-bootstrap [options...]
|
$MYNAME --bs [options...]
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-c, --config build.env
|
-c, --config build.env
|
||||||
--unless-exists
|
-d, --dist DIST
|
||||||
|
--ue, --unless-exists
|
||||||
-U, --pull
|
-U, --pull
|
||||||
-j, --no-cache
|
-j, --nc, --no-cache
|
||||||
-D, --plain-output
|
-D, --po, --plain-output
|
||||||
-x, --apt-proxy APT_PROXY
|
-x, --apt-proxy APT_PROXY
|
||||||
-z, --timezone TIMEZONE
|
-z, --timezone TIMEZONE
|
||||||
-r, --privareg PRIVAREG
|
-r, --privareg PRIVAREG
|
||||||
-p, --push
|
-p, --push
|
||||||
paramètres pour la consruction de l'image"
|
paramètres pour la consruction de l'image
|
||||||
exit 0
|
--ci
|
||||||
;;
|
--cu
|
||||||
-d|--dist) shift; Dist="$1";;
|
lancer composer install (resp. update) après bootstrap
|
||||||
-[0-9]) Dist="d1${1#-}";;
|
--no-use-rslave
|
||||||
--d*) Dist="${1#--}";;
|
paramètre montage des volumes"
|
||||||
-c|--config) shift; Configs+="$1";;
|
exit 0
|
||||||
--ue|--unless-exists) UnlessExists=1;;
|
;;
|
||||||
-U|--pull) Pull=1;;
|
-c|--config) shift; Configs+=("$1");;
|
||||||
-j|--nc|--no-cache) NoCache=1;;
|
-d|--dist) shift; Dist="$1";;
|
||||||
-D|--po|--plain-output) PlainOutput=1;;
|
-[0-9]) Dist="d1${1#-}";;
|
||||||
-x|--apt-proxy) shift; APT_PROXY="$1";;
|
--d*) Dist="${1#--}";;
|
||||||
-z|--timezone) shift; TIMEZONE="$1";;
|
--ue|--unless-exists) UnlessExists=1;;
|
||||||
-r|--privareg) shift; PRIVAREG="$1";;
|
-U|--pull) Pull=1;;
|
||||||
-p|--push) Push=1;;
|
-j|--nc|--no-cache) NoCache=1;;
|
||||||
--ci) ComposerInstall=ci;;
|
-D|--po|--plain-output) PlainOutput=1;;
|
||||||
--cu) ComposerInstall=cu;;
|
-x|--apt-proxy) shift; APT_PROXY="$1";;
|
||||||
--no-use-rslave) UseRslave=;;
|
-z|--timezone) shift; TIMEZONE="$1";;
|
||||||
*) die "$1: option non configurée";;
|
-r|--privareg) shift; PRIVAREG="$1";;
|
||||||
esac
|
-p|--push) Push=1;;
|
||||||
shift
|
--ci) Composer=ci;;
|
||||||
done
|
--cu) Composer=cu;;
|
||||||
|
--no-use-rslave) UseRslave=;;
|
||||||
|
*) die "$1: option non configurée";;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
Cmd=("$@")
|
||||||
|
|
||||||
|
for config in "${Configs[@]}"; do
|
||||||
|
if [ "$config" == none ]; then
|
||||||
|
Configs=()
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ ${#Configs[*]} -gt 0 ]; then
|
||||||
for config in "${Configs[@]}"; do
|
for config in "${Configs[@]}"; do
|
||||||
if [ "$config" == none ]; then
|
source "$config" || exit 1
|
||||||
Configs=()
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
if [ ${#Configs[*]} -gt 0 ]; then
|
after_source_buildenv
|
||||||
for config in "${Configs[@]}"; do
|
fi
|
||||||
source "$config" || exit 1
|
[ -n "$Dist" ] && DIST="$Dist"
|
||||||
done
|
|
||||||
after_source_buildenv
|
|
||||||
fi
|
|
||||||
[ -n "$Dist" ] && DIST="$Dist"
|
|
||||||
|
|
||||||
ensure_image
|
Image=
|
||||||
check_image && exists=1 || exists=
|
host_ensure_image
|
||||||
if [ -z "$UnlessExists" -o -z "$exists" ]; then
|
host_check_image && exists=1 || exists=
|
||||||
eecho "== Building $Image"
|
|
||||||
args=(
|
|
||||||
-f "$Dockerfile"
|
|
||||||
${Pull:+--pull}
|
|
||||||
${NoCache:+--no-cache}
|
|
||||||
${BuildPlain:+--progress plain}
|
|
||||||
-t "$Image"
|
|
||||||
)
|
|
||||||
for arg in "${BUILD_ARGS[@]}"; do
|
|
||||||
args+=(--build-arg "$arg=${!arg}")
|
|
||||||
done
|
|
||||||
for arg in "${!PROXY_VARS[@]}"; do
|
|
||||||
args+=(--build-arg "$arg=${PROXY_VARS[$arg]}")
|
|
||||||
done
|
|
||||||
for host in "${HOST_MAPPINGS[@]}"; do
|
|
||||||
args+=(--add-host "$host")
|
|
||||||
done
|
|
||||||
mkdir -p /tmp/runphp-build
|
|
||||||
docker build "${args[@]}" /tmp/runphp-build || exit 1
|
|
||||||
|
|
||||||
if [ -n "$Push" -a -n "$PRIVAREG" ]; then
|
if [ -z "$UnlessExists" -o -z "$exists" ]; then
|
||||||
eecho "== Pushing $Image"
|
eecho "== Building $Image"
|
||||||
docker push "$Image" || exit 1
|
args=(
|
||||||
fi
|
-f "$Dockerfile"
|
||||||
fi
|
${Pull:+--pull}
|
||||||
if [ -z "$RUNPHP_STANDALONE" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
|
${NoCache:+--no-cache}
|
||||||
# Forcer l'installation des dépendances si nécessaire
|
${BuildPlain:+--progress plain}
|
||||||
[ -n "$ComposerInstall" ] || ComposerInstall=ci
|
-t "$Image"
|
||||||
fi
|
)
|
||||||
|
for arg in "${BUILD_ARGS[@]}"; do
|
||||||
|
args+=(--build-arg "$arg=${!arg}")
|
||||||
|
done
|
||||||
|
for arg in "${!PROXY_VARS[@]}"; do
|
||||||
|
args+=(--build-arg "$arg=${PROXY_VARS[$arg]}")
|
||||||
|
done
|
||||||
|
for host in "${HOST_MAPPINGS[@]}"; do
|
||||||
|
args+=(--add-host "$host")
|
||||||
|
done
|
||||||
|
mkdir -p /tmp/runphp-build
|
||||||
|
docker build "${args[@]}" /tmp/runphp-build || exit 1
|
||||||
|
|
||||||
if [ -n "$ForcedBootstrap" ]; then
|
if [ -n "$Push" -a -n "$PRIVAREG" ]; then
|
||||||
# si le bootstrap est forcé, ne continuer que s'il y a des arguments
|
eecho "== Pushing $Image"
|
||||||
[ $# -eq 0 ] && exit 0
|
docker push "$Image" || exit 1
|
||||||
else
|
|
||||||
# si le bootstrap a été demandé, ne continuer que s'il faut
|
|
||||||
# installer les dépendances
|
|
||||||
[ -z "$ComposerInstall" ] && exit 0
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
## Mode exécution de commande ##########################################
|
function host_docker_run() {
|
||||||
# Ici, on a déterminé qu'il faut lancer une commande
|
# lancer une commande avec docker
|
||||||
|
|
||||||
SOPTS=+w:
|
SOPTS=+w:
|
||||||
LOPTS=help,chdir:,no-use-rslave
|
LOPTS=help,chdir:,no-use-rslave
|
||||||
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
|
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
|
||||||
@ -470,7 +460,9 @@ courant est forcé au répertoire du projet composer
|
|||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-w, --chdir CHDIR
|
-w, --chdir CHDIR
|
||||||
aller dans le répertoire spécifié avant de lancer la commande"
|
aller dans le répertoire spécifié avant de lancer la commande
|
||||||
|
--no-use-rslave
|
||||||
|
paramètre montage des volumes"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-w|--chdir) shift; Chdir="$1";;
|
-w|--chdir) shift; Chdir="$1";;
|
||||||
@ -480,13 +472,6 @@ OPTIONS
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$RUNPHP_STANDALONE" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
|
|
||||||
# Forcer l'installation des dépendances si nécessaire
|
|
||||||
ComposerInstall=ci
|
|
||||||
fi
|
|
||||||
|
|
||||||
## Lancer la commande
|
|
||||||
|
|
||||||
args=(
|
args=(
|
||||||
run -it --rm
|
run -it --rm
|
||||||
--name "runphp-$(basename -- "$1")-$$"
|
--name "runphp-$(basename -- "$1")-$$"
|
||||||
@ -514,7 +499,7 @@ OPTIONS
|
|||||||
[ -n "$RUNPHP_STANDALONE" ] &&
|
[ -n "$RUNPHP_STANDALONE" ] &&
|
||||||
[ "${RUNPHP_STANDALONE#$HOME/}" != "$RUNPHP_STANDALONE" ] &&
|
[ "${RUNPHP_STANDALONE#$HOME/}" != "$RUNPHP_STANDALONE" ] &&
|
||||||
mount_runphp=
|
mount_runphp=
|
||||||
else
|
elif [ -n "$PROJDIR" ]; then
|
||||||
# bind mount uniquement le répertoire du projet
|
# bind mount uniquement le répertoire du projet
|
||||||
args+=(-v "$PROJDIR:$PROJDIR${UseRslave:+:rslave}")
|
args+=(-v "$PROJDIR:$PROJDIR${UseRslave:+:rslave}")
|
||||||
mount_composer=1
|
mount_composer=1
|
||||||
@ -543,15 +528,13 @@ OPTIONS
|
|||||||
"$Image"
|
"$Image"
|
||||||
exec "$0" ${Chdir:+-w "$Chdir"}
|
exec "$0" ${Chdir:+-w "$Chdir"}
|
||||||
)
|
)
|
||||||
[ -n "$ComposerInstall" ] && set -- "$ComposerInstall" "$@"
|
|
||||||
[ -n "$Verbose" ] && eecho "\$ docker ${args[*]} $*"
|
[ -n "$Verbose" ] && eecho "\$ docker ${args[*]} $*"
|
||||||
exec docker "${args[@]}" "$@"
|
docker "${args[@]}" "$@"
|
||||||
|
}
|
||||||
else
|
|
||||||
############################################################################
|
|
||||||
# Lancement depuis l'intérieur du container
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
|
function container_exec() {
|
||||||
|
# lancer la commande $@. cette fonction doit être lancée dans le container
|
||||||
|
# docker
|
||||||
if [ -n "$DEVUSER_USERENT" ]; then
|
if [ -n "$DEVUSER_USERENT" ]; then
|
||||||
user="${DEVUSER_USERENT%%:*}"
|
user="${DEVUSER_USERENT%%:*}"
|
||||||
export DEVUSER_USERENT=
|
export DEVUSER_USERENT=
|
||||||
@ -578,7 +561,7 @@ else
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ $# -eq 0 ]; then
|
||||||
die "no command specified"
|
die "no command specified"
|
||||||
elif [ "$1" == ci ]; then
|
elif [ "$1" == ci ]; then
|
||||||
eecho "== installing composer dependencies"
|
eecho "== installing composer dependencies"
|
||||||
@ -596,4 +579,32 @@ else
|
|||||||
fi
|
fi
|
||||||
exec "$@"
|
exec "$@"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
if [ "$RUNPHP_MODE" != docker ]; then
|
||||||
|
# Lancement depuis l'extérieur du container
|
||||||
|
host_parse_args "$@"
|
||||||
|
host_init_env
|
||||||
|
|
||||||
|
Image=
|
||||||
|
if [ "$Bootstrap" == auto ]; then
|
||||||
|
host_ensure_image
|
||||||
|
host_check_image && Bootstrap= || Bootstrap=1
|
||||||
|
fi
|
||||||
|
if [ -n "$Bootstrap" ]; then
|
||||||
|
host_docker_build "${Cmd[@]}"
|
||||||
|
else
|
||||||
|
host_ensure_image
|
||||||
|
fi
|
||||||
|
|
||||||
|
host_check_projdir
|
||||||
|
[ -n "$Composer" ] && host_docker_run "$Composer"
|
||||||
|
|
||||||
|
[ ${#Cmd[*]} -gt 0 ] && host_docker_run "${Cmd[@]}"
|
||||||
|
|
||||||
|
else
|
||||||
|
# Lancement depuis l'intérieur du container
|
||||||
|
container_exec "$@"
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user