maj scripts docker

This commit is contained in:
Jephté Clain 2018-06-03 13:29:53 +04:00
parent 1a2f6c4335
commit 0ae44bd3ed
4 changed files with 51 additions and 20 deletions

1
docker/.dockerignore Normal file
View File

@ -0,0 +1 @@
/b/t/

2
docker/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/b/
/build.env.local

View File

@ -1,12 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- 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
source /etc/ulibauto || exit 1 source /etc/ulibauto || exit 1
cd "$scriptdir"
NAME=ur/nutools
BUILDDIR=b
TRANSDIR="$BUILDDIR/t"
ENVDIR=..
function display_help() { function display_help() {
uecho "$scriptname: construire $NAME uecho "$scriptname: construire $NAME
@ -16,10 +10,33 @@ USAGE
OPTIONS OPTIONS
-b, --build -b, --build
-n, --no-cache -n, --no-cache"
-r, --run"
} }
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 auto=1
prereqs= prereqs=
build= build=
@ -36,24 +53,20 @@ parse_args "$@"; set -- "${args[@]}"
if [ -n "$prereqs" ]; then if [ -n "$prereqs" ]; then
build= build=
run=
elif [ -n "$auto" ]; then elif [ -n "$auto" ]; then
build=1 build=1
fi fi
if [ -n "$build" ]; then if [ -n "$prereqs" ]; then
setx date=date +%y%m%d do_prereqs "$@" || die
args=( fi
-f Dockerfile
-t $NAME:latest
--build-arg "date=$date"
${no_cache:+--no-cache}
)
etitle "Création de l'image docker $NAME" if [ -n "$build" ]; then
docker build "${args[@]}" "$ENVDIR" do_build "$@" || die
eend
fi fi
if [ -n "$run" ]; then if [ -n "$run" ]; then
docker run -it --rm "$NAME" do_run "$@" || die
fi fi

15
docker/build.env Normal file
View File

@ -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() { :; }