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