allow tagging and deployment of tagged app images

This commit is contained in:
Michael Hobbs
2015-06-10 14:21:47 -07:00
parent 03165ee3f8
commit 04a4da7fc5
16 changed files with 300 additions and 102 deletions

View File

@@ -114,23 +114,38 @@ dokku_container_log_verbose_quiet() {
}
verify_app_name() {
local APP="$1"
local APP="$1"; local TAG="$2"
[[ ! -n "$APP" ]] && dokku_log_fail "(verify_app_name) APP must not be null"
[[ ! -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "App $APP does not exist"
IMAGE="dokku/$APP"
if [[ -n "$TAG" ]]; then
IMAGE="dokku/$APP:$TAG"
else
IMAGE="dokku/$APP"
fi
export IMAGE
return 0
}
verify_image() {
local IMAGE="$1"
DOKKU_APP_IMAGES=$(docker images -q $IMAGE)
if [[ -n "$DOKKU_APP_IMAGES" ]]; then
if (docker inspect "$IMAGE" &>/dev/null); then
return 0
else
return 1
fi
}
get_running_image_tag() {
local APP="$1"
[[ ! -n "$APP" ]] && dokku_log_fail "(get_running_image_tag) APP must not be null"
verify_app_name "$APP"
CIDS=( $(get_container_ids $APP) )
RUNNING_IMAGE_TAG=$(docker ps -a --no-trunc | egrep ${CIDS[0]} 2>/dev/null | awk '{ print $2 }' | awk -F: '{ print $2 }' || echo '')
echo $RUNNING_IMAGE_TAG
}
is_image_herokuish_based() {
# circleci can't support --rm as they run lxc in lxc
[[ ! -f "/home/ubuntu/.circlerc" ]] && local DOCKER_ARGS="--rm"
@@ -267,3 +282,23 @@ is_app_running() {
return 1
fi
}
release_and_deploy() {
local APP="$1"; local TAG="$2"; verify_app_name "$APP" "$TAG"
if verify_image "$IMAGE"; then
if is_image_herokuish_based "$IMAGE"; then
IMAGE_SOURCE_TYPE="herokuish"
else
IMAGE_SOURCE_TYPE="dockerfile"
fi
dokku_log_info1 "Releasing $APP ($IMAGE)..."
dokku release "$APP" "$IMAGE_SOURCE_TYPE" "$TAG"
dokku_log_info1 "Deploying $APP ($IMAGE)..."
dokku deploy "$APP" "$TAG"
dokku_log_info2 "Application deployed:"
dokku urls $APP | sed "s/^/ /"
echo
fi
}