diff --git a/docker/.dockerignore b/docker/.dockerignore new file mode 100644 index 0000000..dcf0102 --- /dev/null +++ b/docker/.dockerignore @@ -0,0 +1 @@ +/b/t/ diff --git a/docker/.gitignore b/docker/.gitignore new file mode 100644 index 0000000..0797d89 --- /dev/null +++ b/docker/.gitignore @@ -0,0 +1,2 @@ +/b/ +/build.env.local diff --git a/docker/build b/docker/build index 9833541..65989cf 100755 --- a/docker/build +++ b/docker/build @@ -1,12 +1,6 @@ #!/bin/bash # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 source /etc/ulibauto || exit 1 -cd "$scriptdir" - -NAME=ur/nutools -BUILDDIR=b -TRANSDIR="$BUILDDIR/t" -ENVDIR=.. function display_help() { uecho "$scriptname: construire $NAME @@ -16,10 +10,33 @@ USAGE OPTIONS -b, --build - -n, --no-cache - -r, --run" + -n, --no-cache" } +function do_prereqs() { + : +} +function do_build() { + local date; local -a args + setx date=date +%y%m%d + args=( + -f Dockerfile + -t $NAME:latest + --build-arg "date=$date" + ${no_cache:+--no-cache} + ) + + etitle "Création de l'image docker $NAME" \ + docker build "${args[@]}" "$CTXDIR" +} +function do_run() { + docker run -it --rm "$NAME" +} + +cd "$scriptdir" +source ./build.env || die "Impossible de trouver build.env" +[ -f build.env.local ] && source build.env.local + auto=1 prereqs= build= @@ -36,24 +53,20 @@ parse_args "$@"; set -- "${args[@]}" if [ -n "$prereqs" ]; then build= + run= elif [ -n "$auto" ]; then build=1 fi -if [ -n "$build" ]; then - setx date=date +%y%m%d - args=( - -f Dockerfile - -t $NAME:latest - --build-arg "date=$date" - ${no_cache:+--no-cache} - ) +if [ -n "$prereqs" ]; then + do_prereqs "$@" || die +fi - etitle "Création de l'image docker $NAME" - docker build "${args[@]}" "$ENVDIR" - eend +if [ -n "$build" ]; then + do_build "$@" || die fi if [ -n "$run" ]; then - docker run -it --rm "$NAME" + do_run "$@" || die fi + diff --git a/docker/build.env b/docker/build.env new file mode 100644 index 0000000..4b53837 --- /dev/null +++ b/docker/build.env @@ -0,0 +1,15 @@ +# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 +# Nom de l'image +NAME=ur/nutools +# Build context pour docker +CTXDIR=.. +# Répertoire contenant les fichiers nécessaire au build +BUILDDIR=b +# Répertoire temporaire pour construire les fichiers de BUILDDIR. Ce répertoire +# n'est pas transmis au daemon docker +TRANSDIR=b/t + +# Fonctions spécifiques +#function do_prereqs() { :; } +#function do_build() { :; } +#function do_run() { :; }