gérer les tags autrement. ajouter push

This commit is contained in:
Jephté Clain 2018-10-08 11:50:56 +04:00
parent 566f1d7afb
commit 48c662be2e
1 changed files with 39 additions and 5 deletions

44
dk
View File

@ -10,6 +10,7 @@ USAGE
COMMANDES
build
push
run
up
logs
@ -84,6 +85,15 @@ function compose_set_env_args() {
fi
}
function initialize_build_env() {
CTXDIR=.
NAME=
TAGS=(latest)
VERSION=
}
function default_update_build_env() { :; }
function update_build_env() { default_update_build_env; }
function default_compose_build() {
docker-compose \
"${replace_env_args[@]}" "${env_args[@]}" \
@ -92,7 +102,11 @@ function default_compose_build() {
}
function default_docker_build() {
[ -n "$VERSION" ] || docker_add_build_arg VERSION "$(get_version)"
replace_build_args+=(-t "$NAME:$VERSION" -t "$NAME:latest")
[ -n "$VERSION" ] && TAGS+=("$VERSION")
local tag
for tag in "${TAGS[@]}"; do
replace_build_args+=(-t "$NAME:$tag")
done
docker build \
"${replace_env_args[@]}" "${env_args[@]}" \
"${replace_build_args[@]}" "${build_args[@]}" \
@ -103,20 +117,30 @@ function docker_build() { default_docker_build "$@"; }
function auto_build() {
local -a replace_env_args env_args
local -a replace_build_args build_args
CTXDIR=.
NAME=
VERSION=
initialize_build_env
if [ -f docker-compose.yml ]; then
compose_set_env_args
update_build_env
compose_build
else
docker_parse_env_args
docker_check_name
docker_add_build_arg build_date "$(date +%y%m%d)"
update_build_env
docker_build
fi
}
function auto_push() {
local -a tags tag
initialize_build_env
update_build_env
for tag in "${TAGS[@]}"; do
tags+=("$NAME:$tag")
done
docker push "${tags[@]}"
}
function default_compose_up() {
docker-compose \
"${replace_env_args[@]}" "${env_args[@]}" \
@ -240,7 +264,7 @@ set_defaults dk
chdir=
profile="$PROFILE"
args=(+
args=(
--help '$exit_with display_help'
-d:,--chdir: chdir=
-p:,--profile: profile=
@ -269,6 +293,16 @@ while [ $# -gt 0 ]; do
enote "Profil $profile"
auto_build "${args[@]}" || die
;;
push)
[ -f .build.scripts.sh ] && source ./.build.scripts.sh
[ -f build.scripts.sh ] && source ./build.scripts.sh
args=()
while [ $# -gt 0 -a "$1" != -- ]; do
args+=("$1"); shift
done
enote "Profil $profile"
auto_push "${args[@]}" || die
;;
s|run|start)
args=()
while [ $# -gt 0 -a "$1" != -- ]; do