From f94db2a69d23465957882733fb280617712bbe55 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Sun, 12 May 2024 15:07:31 +0400 Subject: [PATCH] =?UTF-8?q?am=C3=A9liorer=20la=20prise=20en=20charge=20dan?= =?UTF-8?q?s=20les=20projets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash/src/base.output.sh | 5 +++++ support/Dockerfile.cli | 30 ++++++++++++++++++++++++++++++ support/rundk.userconf | 10 +++++++--- support/update-rundk.sh | 26 +++++++++++++++++++++++++- 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 support/Dockerfile.cli diff --git a/bash/src/base.output.sh b/bash/src/base.output.sh index d740e5d..e83c69d 100644 --- a/bash/src/base.output.sh +++ b/bash/src/base.output.sh @@ -549,6 +549,7 @@ function action() { __action "$action" 1>&2 fi eval "$NULIB__ENABLE_SET_X" + return $r } function asuccess() { @@ -559,6 +560,7 @@ function asuccess() { NULIB__INDENT=" " __asuccess "$*" 1>&2 NULIB__ESTACK="${NULIB__ESTACK%:a}" eval "$NULIB__ENABLE_SET_X" + return 0 } function afailure() { # terminer l'action en cours avec le message d'échec $* @@ -568,6 +570,7 @@ function afailure() { NULIB__INDENT=" " __afailure "$*" 1>&2 NULIB__ESTACK="${NULIB__ESTACK%:a}" eval "$NULIB__ENABLE_SET_X" + return 1 } function aresult() { # terminer l'action en cours avec un message de succès ou d'échec $2..* en @@ -584,6 +587,7 @@ function aresult() { fi NULIB__ESTACK="${NULIB__ESTACK%:a}" eval "$NULIB__ENABLE_SET_X" + return $r } function adone() { # terminer l'action en cours avec le message neutre $* @@ -592,4 +596,5 @@ function adone() { [ -n "$*" ] && NULIB__INDENT=" " __adone "$*" 1>&2 NULIB__ESTACK="${NULIB__ESTACK%:a}" eval "$NULIB__ENABLE_SET_X" + return 0 } diff --git a/support/Dockerfile.cli b/support/Dockerfile.cli new file mode 100644 index 0000000..f4f7e48 --- /dev/null +++ b/support/Dockerfile.cli @@ -0,0 +1,30 @@ +# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 +ARG NDIST=12 +ARG REGISTRY=pubdocker.univ-reunion.fr + +FROM $REGISTRY/src/base as base +FROM $REGISTRY/src/php as php + +################################################################################ +FROM debian:${NDIST}-slim as builder +COPY --from=base /g/ /g/ +COPY --from=base /src/ /src/ + +ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE +ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE +RUN /g/build core lite _builder +RUN make -C /src/su-exec + +################################################################################ +FROM debian:${NDIST}-slim + +COPY --from=builder /src/su-exec/su-exec /g/ +COPY --from=base /g/ /g/ +ARG APT_MIRROR SEC_MIRROR APT_PROXY TIMEZONE +ENV APT_MIRROR=$APT_MIRROR SEC_MIRROR=$SEC_MIRROR APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE +RUN /g/build + +COPY --from=php /g/ /g/ +RUN /g/build @php-cli php-utils + +ENTRYPOINT ["/g/entrypoint"] diff --git a/support/rundk.userconf b/support/rundk.userconf index eb3aa47..327a275 100644 --- a/support/rundk.userconf +++ b/support/rundk.userconf @@ -13,12 +13,16 @@ VENDORDIR= BUILDENV0= BUILDENV= +# Listes des images que le script build construit automatiquement +BUILD_IMAGES=(web db) + +## En ce qui concerne DIST et IMAGENAME, les valeurs dans BUILDENV prennent le +## dessus. Elles n'ont donc besoin d'être spécifiées que si BUILDENV *n'est pas* +## utilisé. + # version de debian à utiliser pour l'image # d12=php8.2, d11=php7.4, d10=php7.3 DIST= # Nom de base de l'image (sans le registry), e.g prefix/rundk IMAGENAME= - -# Listes des images que le script build construit automatiquement -BUILD_IMAGES=(web db) diff --git a/support/update-rundk.sh b/support/update-rundk.sh index 41c3897..cfda3b9 100755 --- a/support/update-rundk.sh +++ b/support/update-rundk.sh @@ -1,13 +1,20 @@ #!/bin/bash # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 -source /etc/nulib.sh || exit 1 +source "$(dirname "$0")/../load.sh" || exit 1 +projdir= args=( "Mettre à jour le script rundk" "[path/to/rundk]" + -d:,--projdir:PROJDIR . "Copier les fichiers pour un projet" ) parse_args "$@"; set -- "${args[@]}" +if [ -n "$projdir" ]; then + setx projdir=abspath "$projdir" + set -- "$projdir/sbin/rundk" +fi + rundk="${1:-.}" [ -d "$rundk" ] && rundk="$rundk/rundk" @@ -38,8 +45,10 @@ p == 1 { } } ' >"$userconf" + initial_config= else userconf="$MYDIR/rundk.userconf" + initial_config=1 fi ( @@ -52,3 +61,18 @@ fi [ -x "$rundk" ] || chmod +x "$rundk" rsync -lpt "$MYDIR/Dockerfile.rundk" "$rundir/" + +if [ -n "$projdir" ]; then + if should_update "$rundir/build" "$MYDIR/build"; then + cp "$MYDIR/build" "$rundir/build" + chmod +x "$rundir/build" + fi + if [ ! -f "$projdir/.build.env.dist" ]; then + sed <"$MYDIR/dot-build.env.dist" >"$projdir/.build.env.dist" ' +/^IMAGENAME=/s/=.*\//='"$(basename -- "$projdir")"'\// +' + initial_config=1 + fi +fi + +[ -n "$initial_config" ]