maj rundk
This commit is contained in:
parent
df391263d4
commit
171a6703db
|
@ -0,0 +1,15 @@
|
|||
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||
ARG REGISTRY=pubdocker.univ-reunion.fr
|
||||
FROM $REGISTRY/src/base as base
|
||||
FROM $REGISTRY/src/mariadb as mariadb
|
||||
|
||||
FROM mariadb:10
|
||||
|
||||
COPY --from=base /g/ /g/
|
||||
COPY --from=mariadb /g/ /g/
|
||||
ARG APT_PROXY TIMEZONE
|
||||
ENV APT_PROXY=$APT_PROXY TIMEZONE=$TIMEZONE
|
||||
RUN /g/build -a @base @mariadb
|
||||
|
||||
EXPOSE 3306
|
||||
ENTRYPOINT ["/g/entrypoint"]
|
|
@ -10,6 +10,8 @@ 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
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# -*- 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 -a @apache-php-cas php-utils
|
||||
|
||||
EXPOSE 80
|
||||
ENTRYPOINT ["/g/entrypoint"]
|
|
@ -0,0 +1,150 @@
|
|||
#!/bin/bash
|
||||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||
MYDIR="$(cd "$(dirname -- "$0")"; pwd)"
|
||||
"$MYDIR/rundk" --bs --ue --ci || exit 1
|
||||
source "$MYDIR/rundk" || exit 1
|
||||
source "$PROJDIR/$VENDORDIR/nulib/php/load.sh" || exit 1
|
||||
|
||||
BUILD_ARGS=(
|
||||
DIST NDIST
|
||||
REGISTRY
|
||||
APT_PROXY
|
||||
APT_MIRROR
|
||||
SEC_MIRROR
|
||||
TIMEZONE
|
||||
)
|
||||
|
||||
function dklsnet() {
|
||||
docker network ls --no-trunc --format '{{.Name}}' -f name="$1" 2>/dev/null
|
||||
}
|
||||
|
||||
function dklsimg() {
|
||||
local image="$1" version="$2"
|
||||
docker image ls --no-trunc --format '{{.Repository}}:{{.Tag}}' "$image${version:+:$version}" 2>/dev/null
|
||||
}
|
||||
|
||||
function dklsct() {
|
||||
# afficher le container dont l'image correspondante est $1
|
||||
docker ps --no-trunc --format '{{.Image}} {{.Names}}' | awk -v image="$1" '$1 == image { print $2 }'
|
||||
}
|
||||
|
||||
function dkrunning() {
|
||||
# vérifier si le container d'image $1 tourne
|
||||
[ -n "$(dklsct "$@")" ]
|
||||
}
|
||||
|
||||
function dclsct() {
|
||||
# afficher les containers correspondant à $1(=docker-compose.yml)
|
||||
docker compose ${1:+-f "$1"} ps -q
|
||||
}
|
||||
|
||||
function dcrunning() {
|
||||
# vérifier si les containers correspondant à $1(=docker-compose.yml) tournent
|
||||
# si $2 est spécifié, c'est le nombre de service qui doit tourner
|
||||
if [ -n "$2" ]; then
|
||||
[ "$(dclsct "${@:1:1}" | wc -l)" -eq "$2" ]
|
||||
else
|
||||
[ -n "$(dclsct "${@:1:1}")" ]
|
||||
fi
|
||||
}
|
||||
|
||||
function build_check_env() {
|
||||
eval "$(template_locals)"
|
||||
|
||||
template_copy_missing "$PROJDIR/$BUILDENV0" && updated=1
|
||||
template_process_userfiles
|
||||
|
||||
if [ -n "$updated" ]; then
|
||||
enote "IMPORTANT: Veuillez faire le paramétrage en éditant le fichier $BUILDENV
|
||||
${EDITOR:-nano} $BUILDENV
|
||||
ENSUITE, vous pourrez relancer la commande"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function _build() {
|
||||
local dockerfile image="${PRIVAREG:+$PRIVAREG/}${IMAGENAME%*/}/$1"
|
||||
if [ -n "$ForceBuild" -o -z "$(dklsimg "$image")" ]; then
|
||||
estep "Construction de $image"
|
||||
if [ -f "$PROJDIR/Dockerfile.$1" ]; then dockerfile="$PROJDIR/Dockerfile.$1"
|
||||
elif [ -f "$MYDIR/Dockerfile.$1" ]; then dockerfile="$MYDIR/Dockerfile.$1"
|
||||
else dockerfile="$PROJDIR/$VENDORDIR/nulib/php/support/Dockerfile.$1"
|
||||
fi
|
||||
args=(
|
||||
-f "$dockerfile"
|
||||
${Pull:+--pull}
|
||||
${NoCache:+--no-cache}
|
||||
${PlainOutput:+--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
|
||||
docker build "${args[@]}" "$PROJDIR" || die
|
||||
if [ -n "$Push" ]; then
|
||||
if [ -n "$PRIVAREG" ]; then
|
||||
estep "Poussement de $image"
|
||||
docker push "$image" || die
|
||||
else
|
||||
ewarn "PRIVAREG non défini: impossible de pousser l'image"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
function build_images() {
|
||||
local image sourced
|
||||
|
||||
[ $# -gt 0 ] || set -- rundk db web
|
||||
for image in "$@"; do
|
||||
case "$image" in
|
||||
rundk)
|
||||
local -a args=(--bootstrap)
|
||||
[ -z "$ForceBuild" ] && args+=(--unless-exists)
|
||||
[ -n "$Pull" ] && args+=(--pull)
|
||||
[ -n "$NoCache" ] && args+=(--no-cache)
|
||||
"$MYDIR/rundk" "${args[@]}" || die
|
||||
;;
|
||||
*)
|
||||
if [ -z "$sourced" ]; then
|
||||
source "$PROJDIR/$BUILDENV"
|
||||
read -a HOST_MAPPINGS <<<"${HOST_MAPPINGS//
|
||||
/ }"
|
||||
sourced=1
|
||||
fi
|
||||
_build "$image"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
action=build
|
||||
ForceBuild=
|
||||
Pull=
|
||||
NoCache=
|
||||
PlainOutput=
|
||||
Push=
|
||||
args=(
|
||||
"Construire les images pour DRE"
|
||||
#"usage"
|
||||
--check-only action=none "++Ne faire que la vérification de l'environnement"
|
||||
-r,--rebuild ForceBuild=1 "Forcer la (re)construction de l'image"
|
||||
-U,--pull Pull=1 "++Forcer le re-téléchargement des images dépendantes"
|
||||
-j,--no-cache NoCache=1 "++Construire l'image en invalidant le cache"
|
||||
-D,--plain-output PlainOutput=1 "++Afficher le détail du build"
|
||||
-p,--push Push=1 "Pousser les images vers le registry après construction"
|
||||
)
|
||||
parse_args "$@"; set -- "${args[@]}"
|
||||
|
||||
build_check_env || die
|
||||
[ "$action" == none ] && exit 0
|
||||
|
||||
case "$action" in
|
||||
build) build_images "$@";;
|
||||
*) die "$action: action non implémentée";;
|
||||
esac
|
|
@ -3,16 +3,14 @@
|
|||
# Script permettant de lancer une commande dans docker et/ou de bootstrapper
|
||||
# l'utilisation de nulib dans un projet
|
||||
# Les fichiers suivants doivent être copiés à un endroit quelconque du projet:
|
||||
# - rundk (ce script)
|
||||
# - rundk (ce script, à générer avec update-rundk.sh)
|
||||
# - Dockerfile.rundk
|
||||
# Les fichiers suivants peuvent être intégrés dans le projet comme exemples:
|
||||
# - dot-build.env.dist
|
||||
# - dot-dkbuild.env.dist
|
||||
# Par défaut, ce script assume que bootstrap est copié dans le répertoire sbin/
|
||||
# - dot-build.env.dist (à renommer en .build.env.dist)
|
||||
# - dot-dkbuild.env.dist (à renommer en .dkbuild.env.dist)
|
||||
# Par défaut, ce script assume que rundk est copié dans le répertoire sbin/
|
||||
# du projet, et que le fichier composer.json et le répertoire vendor/ sont à la
|
||||
# racine du projet. Le cas échéant, modifier les valeurs ci-dessous
|
||||
MYDIR="$(cd "$(dirname -- "$0")"; pwd)"
|
||||
MYNAME="$(basename -- "$0")"
|
||||
|
||||
###############################################################################
|
||||
# Modifier les valeurs suivantes si nécessaire
|
||||
|
|
|
@ -3,7 +3,19 @@
|
|||
|
||||
# Ne pas modifier à partir d'ici
|
||||
|
||||
if [ "${0#-}" != "$0" ]; then
|
||||
# sourcé depuis la ligne de commande
|
||||
MYSELF="${BASH_SOURCE[1]}"
|
||||
MYDIR="$(cd "$(dirname -- "$MYSELF")"; pwd)"
|
||||
MYNAME="$(basename -- "$MYSELF")"
|
||||
else
|
||||
MYDIR="$(cd "$(dirname -- "$0")"; pwd)"
|
||||
MYNAME="$(basename -- "$0")"
|
||||
fi
|
||||
|
||||
[ -n "$PROJDIR" ] || PROJDIR="$(dirname -- "$MYDIR")"
|
||||
[ "${PROJDIR#/}" != "$PROJDIR" ] || PROJDIR="$(cd "$MYDIR/$PROJDIR"; pwd)"
|
||||
|
||||
[ -n "$COMPOSERDIR" ] || COMPOSERDIR=.
|
||||
[ -n "$COMPOSERPHAR" ] || COMPOSERPHAR=sbin/composer.phar
|
||||
[ -n "$VENDORDIR" ] || VENDORDIR=vendor
|
||||
|
@ -16,6 +28,10 @@
|
|||
[ "$BUILDENV0" == none ] && BUILDENV0=
|
||||
[ "$BUILDENV" == none ] && BUILDENV=
|
||||
|
||||
NDIST="${DIST#d}"
|
||||
|
||||
(return 0 2>/dev/null) && return 0
|
||||
|
||||
function eecho() { echo "$*" 1>&2; }
|
||||
function eerror() { eecho "ERROR: $*"; }
|
||||
function die() { [ $# -gt 0 ] && eerror "$*"; exit 1; }
|
||||
|
@ -176,6 +192,7 @@ if [ -z "$_RUNDK_IN_DOCKER" ]; then
|
|||
|
||||
if [ -n "$bootstrap" ]; then
|
||||
BUILD_ARGS=(
|
||||
DIST NDIST
|
||||
REGISTRY
|
||||
APT_PROXY
|
||||
APT_MIRROR
|
||||
|
@ -264,7 +281,6 @@ OPTIONS
|
|||
${NoCache:+--no-cache}
|
||||
${BuildPlain:+--progress plain}
|
||||
-t "$IMAGE"
|
||||
--build-arg "NDIST=${DIST#d}"
|
||||
)
|
||||
for arg in "${BUILD_ARGS[@]}"; do
|
||||
args+=(--build-arg "$arg=${!arg}")
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# répertoire du projet. ce chemin doit être absolu
|
||||
# répertoire du projet. ce chemin doit être absolu. s'il est relatif, il est
|
||||
# exprimé par rapport au répertoire de ce script
|
||||
PROJDIR=
|
||||
|
||||
# composer: répertoire du projet composer (celui qui contient le fichier
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
#!/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
|
||||
|
||||
args=(
|
||||
"Mettre à jour le script rundk"
|
||||
"[path/to/rundk]"
|
||||
)
|
||||
parse_args "$@"; set -- "${args[@]}"
|
||||
|
||||
rundk="${1:-.}"
|
||||
[ -d "$rundk" ] && rundk="$rundk/rundk"
|
||||
|
||||
setx rundir=dirname -- "$rundk"
|
||||
[ -d "$rundir" ] || mkdir -p "$rundir"
|
||||
|
||||
if [ -f "$rundk" ]; then
|
||||
ac_set_tmpfile userconf
|
||||
<"$rundk" awk '
|
||||
# extraire la configuration depuis le fichier
|
||||
BEGIN { p = 0 }
|
||||
/SOF:rundk.userconf:/ { p = 1; next }
|
||||
/EOF:rundk.userconf:/ { p = 0; next }
|
||||
p == 1 { print }
|
||||
' | awk '
|
||||
# mettre en forme le fichier: pas de lignes vides avant et après
|
||||
BEGIN { p = 0; have_pending = 0; pending = "" }
|
||||
$0 != "" { p = 1 }
|
||||
p == 1 {
|
||||
if ($0 != "") {
|
||||
if (have_pending) print pending
|
||||
print
|
||||
have_pending = 0
|
||||
pending = ""
|
||||
} else {
|
||||
if (!have_pending) have_pending = 1
|
||||
else pending = pending "\n"
|
||||
}
|
||||
}
|
||||
' >"$userconf"
|
||||
else
|
||||
userconf="$MYDIR/rundk.userconf"
|
||||
fi
|
||||
|
||||
(
|
||||
cat "$MYDIR/rundk.1preamble"
|
||||
echo
|
||||
cat "$userconf"
|
||||
echo
|
||||
cat "$MYDIR/rundk.2postamble"
|
||||
) >"$rundk"
|
||||
[ -x "$rundk" ] || chmod +x "$rundk"
|
Loading…
Reference in New Issue