fix: properly support new image and image-version values during plugin upgrades
Closes dokku/dokku-mongo#143 Closes dokku/dokku-redis#193 Closes dokku/dokku-redis#195
This commit is contained in:
@@ -501,12 +501,18 @@ service_exposed_ports() {
|
|||||||
|
|
||||||
service_image_exists() {
|
service_image_exists() {
|
||||||
declare desc="check if the current image exists"
|
declare desc="check if the current image exists"
|
||||||
declare SERVICE="$1"
|
declare SERVICE="$1" PLUGIN_IMAGE="${2:-$PLUGIN_IMAGE}" PLUGIN_IMAGE_VERSION="${3:-$PLUGIN_IMAGE_VERSION}"
|
||||||
local plugin_image="$PLUGIN_IMAGE"
|
local plugin_image="$PLUGIN_IMAGE"
|
||||||
local plugin_image_version="$PLUGIN_IMAGE_VERSION"
|
local plugin_image_version="$PLUGIN_IMAGE_VERSION"
|
||||||
|
|
||||||
[[ -f "$SERVICE_ROOT/IMAGE" ]] && plugin_image="$(cat "$SERVICE_ROOT/IMAGE")"
|
if [[ -z "$PLUGIN_IMAGE" ]] && [[ -f "$SERVICE_ROOT/IMAGE" ]]; then
|
||||||
[[ -f "$SERVICE_ROOT/IMAGE_VERSION" ]] && plugin_image_version="$(cat "$SERVICE_ROOT/IMAGE_VERSION")"
|
plugin_image="$(cat "$SERVICE_ROOT/IMAGE")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$PLUGIN_IMAGE_VERSION" ]] && [[ -f "$SERVICE_ROOT/IMAGE_VERSION" ]]; then
|
||||||
|
plugin_image_version="$(cat "$SERVICE_ROOT/IMAGE_VERSION")"
|
||||||
|
fi
|
||||||
|
|
||||||
local IMAGE="$plugin_image:$plugin_image_version"
|
local IMAGE="$plugin_image:$plugin_image_version"
|
||||||
|
|
||||||
if [[ "$("$DOCKER_BIN" image ls -q "$IMAGE" 2>/dev/null)" == "" ]]; then
|
if [[ "$("$DOCKER_BIN" image ls -q "$IMAGE" 2>/dev/null)" == "" ]]; then
|
||||||
|
|||||||
@@ -28,17 +28,7 @@ service-upgrade-cmd() {
|
|||||||
|
|
||||||
service_parse_args "${@:2}"
|
service_parse_args "${@:2}"
|
||||||
|
|
||||||
if ! service_image_exists "$SERVICE"; then
|
if ! service_image_exists "$SERVICE" "$PLUGIN_IMAGE" "$PLUGIN_IMAGE_VERSION"; then
|
||||||
dokku_log_fail "Unable to proceed with upgrade, image ${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION} does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local NEW_PLUGIN_IMAGE_TAG="$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION"
|
|
||||||
if [[ "$(service_version "$SERVICE")" == "$NEW_PLUGIN_IMAGE_TAG" ]]; then
|
|
||||||
dokku_log_info1 "Service $SERVICE already running $NEW_PLUGIN_IMAGE_TAG"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! service_image_exists "$SERVICE"; then
|
|
||||||
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
|
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
|
||||||
dokku_log_warn "${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
|
dokku_log_warn "${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
|
||||||
dokku_log_warn " docker image pull ${IMAGE}" 1>&2
|
dokku_log_warn " docker image pull ${IMAGE}" 1>&2
|
||||||
@@ -48,6 +38,12 @@ service-upgrade-cmd() {
|
|||||||
"$DOCKER_BIN" image pull "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" || dokku_log_fail "$PLUGIN_SERVICE image $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION pull failed"
|
"$DOCKER_BIN" image pull "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" || dokku_log_fail "$PLUGIN_SERVICE image $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION pull failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local NEW_PLUGIN_IMAGE_TAG="$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION"
|
||||||
|
if [[ "$(service_version "$SERVICE")" == "$NEW_PLUGIN_IMAGE_TAG" ]]; then
|
||||||
|
dokku_log_info1 "Service $SERVICE already running $NEW_PLUGIN_IMAGE_TAG"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
service_commit_config "$SERVICE"
|
service_commit_config "$SERVICE"
|
||||||
|
|
||||||
dokku_log_info2 "Upgrading $SERVICE to $NEW_PLUGIN_IMAGE_TAG"
|
dokku_log_info2 "Upgrading $SERVICE to $NEW_PLUGIN_IMAGE_TAG"
|
||||||
|
|||||||
Reference in New Issue
Block a user