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
# -*- 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

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