Compare commits
3 Commits
eb8684275e
...
82541bfc1c
Author | SHA1 | Date | |
---|---|---|---|
82541bfc1c | |||
8b34d8da6b | |||
f44d9ef404 |
@ -4,5 +4,5 @@
|
|||||||
RUNPHP=
|
RUNPHP=
|
||||||
|
|
||||||
# Si RUNPHP n'est pas défini, les variables suivantes peuvent être définies
|
# Si RUNPHP n'est pas défini, les variables suivantes peuvent être définies
|
||||||
DIST=d11
|
DIST=d12
|
||||||
#REGISTRY=pubdocker.univ-reunion.fr/dist
|
#REGISTRY=pubdocker.univ-reunion.fr/dist
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"symfony/yaml": "^5.0",
|
"symfony/yaml": "^7.1",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"php": "^7.4"
|
"php": "^8.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"nulib/tests": "^7.4",
|
"nulib/tests": "^8.2",
|
||||||
"ext-posix": "*",
|
"ext-posix": "*",
|
||||||
"ext-pcntl": "*",
|
"ext-pcntl": "*",
|
||||||
"ext-curl": "*"
|
"ext-curl": "*"
|
||||||
|
64
runphp/build
64
runphp/build
@ -2,10 +2,11 @@
|
|||||||
# -*- 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
|
||||||
MYDIR="$(cd "$(dirname -- "$0")"; pwd)"
|
MYDIR="$(cd "$(dirname -- "$0")"; pwd)"
|
||||||
RUNPHP="$MYDIR/runphp"
|
RUNPHP="$MYDIR/runphp"
|
||||||
"$RUNPHP" --bs --ue || exit 1
|
"$RUNPHP" --bs --ue --ci || exit 1
|
||||||
RUNPHP_STANDALONE=
|
RUNPHP_STANDALONE=
|
||||||
PROJDIR=; COMPOSERDIR=; COMPOSERPHAR=; VENDORDIR=; BUILDENV0=; BUILDENV=
|
PROJDIR=; COMPOSERDIR=; COMPOSERPHAR=; VENDORDIR=; BUILDENV0=; BUILDENV=
|
||||||
BUILD_IMAGES=(php-apache mariadb10); export BUILD_FLAVOUR=; DIST=; IMAGENAME=
|
BUILD_IMAGES=(php-apache mariadb10); export BUILD_FLAVOUR=; DIST=; IMAGENAME=
|
||||||
|
DISTFILES=()
|
||||||
source "$RUNPHP" || exit 1
|
source "$RUNPHP" || exit 1
|
||||||
source "$PROJDIR/$VENDORDIR/nulib/php/load.sh" || exit 1
|
source "$PROJDIR/$VENDORDIR/nulib/php/load.sh" || exit 1
|
||||||
require: template
|
require: template
|
||||||
@ -55,26 +56,65 @@ function dcrunning() {
|
|||||||
|
|
||||||
function build_check_env() {
|
function build_check_env() {
|
||||||
eval "$(template_locals)"
|
eval "$(template_locals)"
|
||||||
|
local updatedenv distfile distname
|
||||||
|
local -a updatedfiles distfiles
|
||||||
|
|
||||||
template_copy_missing "$PROJDIR/$BUILDENV0" && updated=1
|
if template_copy_missing "$PROJDIR/$BUILDENV0"; then
|
||||||
|
updated=1
|
||||||
|
updatedenv=1
|
||||||
|
fi
|
||||||
|
for distfile in "${DISTFILES[@]}"; do
|
||||||
|
if [ -f "$PROJDIR/$distfile" ]; then
|
||||||
|
if template_copy_missing "$PROJDIR/$distfile"; then
|
||||||
|
updated=1
|
||||||
|
setx distname=basename -- "$distfile"
|
||||||
|
distname="${distname#.}"; distname="${distname%.dist}"
|
||||||
|
setx distfile=dirname -- "$distfile"
|
||||||
|
distfile="$distfile/$distname"
|
||||||
|
updatedfiles+=("$distfile")
|
||||||
|
fi
|
||||||
|
elif [ -d "$PROJDIR/$distfile" ]; then
|
||||||
|
local distdir="$PROJDIR/$distfile"
|
||||||
|
setx -a distfiles=find "$distdir" -type f -name ".*.dist"
|
||||||
|
for distfile in "${distfiles[@]}"; do
|
||||||
|
if template_copy_missing "$distfile"; then
|
||||||
|
updated=1
|
||||||
|
setx distname=basename -- "$distfile"
|
||||||
|
distname="${distname#.}"; distname="${distname%.dist}"
|
||||||
|
setx distfile=dirname -- "$distfile"
|
||||||
|
distfile="$distfile/$distname"
|
||||||
|
updatedfiles+=("${distfile#$PROJDIR/}")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
ewarn "$distfile: fichier introuvable"
|
||||||
|
fi
|
||||||
|
done
|
||||||
template_process_userfiles
|
template_process_userfiles
|
||||||
|
|
||||||
if [ -n "$updated" ]; then
|
if [ -n "$updated" ]; then
|
||||||
if [ $(id -u) -ne 0 ]; then
|
enote "IMPORTANT: vous devez paramétrer certains fichiers avant de pouvoir construire les images"
|
||||||
setx userent=getent passwd "$(id -un)"
|
if [ -n "$updatedenv" ]; then
|
||||||
setx userent=qval "$userent"
|
if [ -a $(id -u) -ne 0 ]; then
|
||||||
setx groupent=getent group "$(id -gn)"
|
setx userent=getent passwd "$(id -un)"
|
||||||
setx groupent=qval "$groupent"
|
setx userent=qval "$userent"
|
||||||
sed -i "
|
setx groupent=getent group "$(id -gn)"
|
||||||
|
setx groupent=qval "$groupent"
|
||||||
|
sed -i "
|
||||||
/^#DEVUSER_.*=/s/^#//
|
/^#DEVUSER_.*=/s/^#//
|
||||||
/^DEVUSER_USERENT=/s/=.*/=${userent//\//\\\/}/
|
/^DEVUSER_USERENT=/s/=.*/=${userent//\//\\\/}/
|
||||||
/^DEVUSER_GROUPENT=/s/=.*/=${groupent//\//\\\/}/
|
/^DEVUSER_GROUPENT=/s/=.*/=${groupent//\//\\\/}/
|
||||||
" "$PROJDIR/$BUILDENV"
|
" "$PROJDIR/$BUILDENV"
|
||||||
|
fi
|
||||||
|
enote "\
|
||||||
|
Veuillez vérifier le fichier $BUILDENV
|
||||||
|
${EDITOR:-nano} $BUILDENV"
|
||||||
fi
|
fi
|
||||||
|
[ ${#updatedfiles[*]} -gt 0 ] && enote "\
|
||||||
enote "IMPORTANT: Veuillez faire le paramétrage en éditant le fichier $BUILDENV
|
Le cas échéant, veuillez vérifier ce(s) fichier(s)
|
||||||
${EDITOR:-nano} $BUILDENV
|
${EDITOR:-nano} $(qvals "${updatedfiles[@]}")"
|
||||||
ENSUITE, vous pourrez relancer la commande"
|
enote "ENSUITE, vous pourrez relancer la commande"
|
||||||
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,14 @@ DIST=
|
|||||||
# Nom de base de l'image (sans le registry), e.g prefix/
|
# Nom de base de l'image (sans le registry), e.g prefix/
|
||||||
IMAGENAME=
|
IMAGENAME=
|
||||||
|
|
||||||
|
## Fichiers .dist
|
||||||
|
## Lors du build, les fichiers de la forme .name.dist sont copiés vers un
|
||||||
|
## fichier name sauf s'il existe déjà
|
||||||
|
|
||||||
|
# Liste de fichiers (ou de répertoirs à considérer). Pour chaque répertoire, les
|
||||||
|
# fichiers .*.dist dans l'arborescence du répertoire sont recherchés
|
||||||
|
DISTFILES=()
|
||||||
|
|
||||||
#EOF:runphp.userconf:ne pas modifier cette ligne
|
#EOF:runphp.userconf:ne pas modifier cette ligne
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
@ -219,7 +227,6 @@ function host_check_projdir() {
|
|||||||
install=1
|
install=1
|
||||||
fi
|
fi
|
||||||
if [ -n "$install" ]; then
|
if [ -n "$install" ]; then
|
||||||
eecho "== bootstrapping runphp"
|
|
||||||
[ -n "$Composer" ] || Composer=ci
|
[ -n "$Composer" ] || Composer=ci
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -314,6 +321,7 @@ function host_init_env() {
|
|||||||
|
|
||||||
Chdir=
|
Chdir=
|
||||||
Verbose="$RUNPHP_VERBOSE"
|
Verbose="$RUNPHP_VERBOSE"
|
||||||
|
Exec=
|
||||||
}
|
}
|
||||||
|
|
||||||
function host_docker_build() {
|
function host_docker_build() {
|
||||||
@ -359,7 +367,7 @@ OPTIONS
|
|||||||
paramètres pour la consruction de l'image
|
paramètres pour la consruction de l'image
|
||||||
--ci
|
--ci
|
||||||
--cu
|
--cu
|
||||||
lancer composer install (resp. update) après bootstrap
|
lancer composer install (resp. update) s'il y a eu bootstrap
|
||||||
--no-use-rslave
|
--no-use-rslave
|
||||||
paramètre montage des volumes"
|
paramètre montage des volumes"
|
||||||
exit 0
|
exit 0
|
||||||
@ -404,7 +412,7 @@ OPTIONS
|
|||||||
host_check_image && exists=1 || exists=
|
host_check_image && exists=1 || exists=
|
||||||
|
|
||||||
if [ -z "$UnlessExists" -o -z "$exists" ]; then
|
if [ -z "$UnlessExists" -o -z "$exists" ]; then
|
||||||
eecho "== Building $Image"
|
eecho "== bootstrapping $Image"
|
||||||
args=(
|
args=(
|
||||||
-f "$Dockerfile"
|
-f "$Dockerfile"
|
||||||
${Pull:+--pull}
|
${Pull:+--pull}
|
||||||
@ -428,6 +436,9 @@ OPTIONS
|
|||||||
eecho "== Pushing $Image"
|
eecho "== Pushing $Image"
|
||||||
docker push "$Image" || exit 1
|
docker push "$Image" || exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
# s'il n'y a pas eu bootstrap, alors ne pas lancer la commande composer
|
||||||
|
Composer=
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,9 +456,14 @@ function host_docker_run() {
|
|||||||
runphp: lancer une commande dans un environnement PHP déterminé
|
runphp: lancer une commande dans un environnement PHP déterminé
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
|
$MYNAME --bs ...
|
||||||
$MYNAME ci|cu|composer
|
$MYNAME ci|cu|composer
|
||||||
$MYNAME [options] command [args...]
|
$MYNAME [options] command [args...]
|
||||||
|
|
||||||
|
COMMANDES SPECIALES
|
||||||
|
--bs
|
||||||
|
faire un bootstrap de l'image runphp
|
||||||
|
|
||||||
COMMANDES COMPOSER
|
COMMANDES COMPOSER
|
||||||
ci
|
ci
|
||||||
cu
|
cu
|
||||||
@ -529,7 +545,7 @@ OPTIONS
|
|||||||
exec "$0" ${Chdir:+-w "$Chdir"}
|
exec "$0" ${Chdir:+-w "$Chdir"}
|
||||||
)
|
)
|
||||||
[ -n "$Verbose" ] && eecho "\$ docker ${args[*]} $*"
|
[ -n "$Verbose" ] && eecho "\$ docker ${args[*]} $*"
|
||||||
docker "${args[@]}" "$@"
|
${Exec:+exec} docker "${args[@]}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function container_exec() {
|
function container_exec() {
|
||||||
@ -605,12 +621,10 @@ if [ "$RUNPHP_MODE" != docker ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${#Cmd[*]} -gt 0 ]; then
|
if [ ${#Cmd[*]} -gt 0 ]; then
|
||||||
host_docker_run "${Cmd[@]}" || exit $?
|
Exec=1 host_docker_run "${Cmd[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
# Lancement depuis l'intérieur du container
|
# Lancement depuis l'intérieur du container
|
||||||
container_exec "$@"
|
container_exec "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
Reference in New Issue
Block a user