2018-06-02 18:20:02 +04:00
|
|
|
#!/bin/bash
|
|
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
|
|
source /etc/ulibauto || exit 1
|
|
|
|
|
|
|
|
function display_help() {
|
|
|
|
uecho "$scriptname: construire $NAME
|
|
|
|
|
|
|
|
USAGE
|
|
|
|
$scriptname [options]
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
-b, --build
|
2018-06-03 13:29:53 +04:00
|
|
|
-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"
|
2018-06-02 18:20:02 +04:00
|
|
|
}
|
|
|
|
|
2018-06-03 13:29:53 +04:00
|
|
|
cd "$scriptdir"
|
|
|
|
source ./build.env || die "Impossible de trouver build.env"
|
|
|
|
[ -f build.env.local ] && source build.env.local
|
|
|
|
|
2018-06-02 18:20:02 +04:00
|
|
|
auto=1
|
|
|
|
prereqs=
|
|
|
|
build=
|
|
|
|
no_cache=
|
2018-06-02 19:52:40 +04:00
|
|
|
run=
|
2018-06-02 18:20:02 +04:00
|
|
|
args=(
|
|
|
|
--help '$exit_with display_help'
|
|
|
|
--prereqs '$prereqs=1; auto='
|
|
|
|
-b,--build '$build=1; auto='
|
|
|
|
-n,--no-cache no_cache=1
|
2018-06-02 19:52:40 +04:00
|
|
|
-r,--run '$run=1; auto='
|
2018-06-02 18:20:02 +04:00
|
|
|
)
|
|
|
|
parse_args "$@"; set -- "${args[@]}"
|
|
|
|
|
|
|
|
if [ -n "$prereqs" ]; then
|
|
|
|
build=
|
2018-06-03 13:29:53 +04:00
|
|
|
run=
|
2018-06-02 18:20:02 +04:00
|
|
|
elif [ -n "$auto" ]; then
|
|
|
|
build=1
|
|
|
|
fi
|
|
|
|
|
2018-06-03 13:29:53 +04:00
|
|
|
if [ -n "$prereqs" ]; then
|
|
|
|
do_prereqs "$@" || die
|
|
|
|
fi
|
2018-06-02 18:20:02 +04:00
|
|
|
|
2018-06-03 13:29:53 +04:00
|
|
|
if [ -n "$build" ]; then
|
|
|
|
do_build "$@" || die
|
2018-06-02 18:20:02 +04:00
|
|
|
fi
|
2018-06-02 19:52:40 +04:00
|
|
|
|
|
|
|
if [ -n "$run" ]; then
|
2018-06-03 13:29:53 +04:00
|
|
|
do_run "$@" || die
|
2018-06-02 19:52:40 +04:00
|
|
|
fi
|
2018-06-03 13:29:53 +04:00
|
|
|
|