diff --git a/build b/build index 85adacf..0117f6a 100755 --- a/build +++ b/build @@ -15,25 +15,18 @@ minor_version="$(echo "$patch_version" | branch="$(git branch --show-current)" if [[ "$branch" = "master" ]]; then - tags=("$patch_version" "$minor_version" "$major_version" "latest" ) + tags=("$patch_version" "$minor_version" "$major_version" "latest") elif [[ "$branch" = "develop" ]]; then - tags=("$patch_version-dev" "$minor_version-dev" "$major_version-dev" ) + tags=("$patch_version-dev" "$minor_version-dev" "$major_version-dev" "dev") else tags=("$branch") fi -tag_flags=() - -for tag in "${tags[@]}"; do - tag_flags+=("-t $1:$tag") - -done - # Run the actual build command -docker build $tag_flags . +docker build -t "$1:$tags" . if [[ "$2" = push ]]; then [[ "$branch" =~ ^develop|master$ ]] || { @@ -42,7 +35,14 @@ if [[ "$2" = push ]]; then } for tag in "${tags[@]}"; do + # Create the tag + docker tag "$1:$tags" "$1:$tag" + + # Push the tag docker push "$1:$tag" + + # Remove the tag again, if it's not the main tag + [[ "$tag" != "$tags" ]] && docker rmi "$1:$tag" done elif [[ "$2" = run ]]; then