From bd2e292e1e0bc4aad4e80a442b7eea6d6c24c937 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 11 Apr 2018 15:11:58 -0400 Subject: [PATCH] feat: use custom env var to disable pull actions --- README.md | 6 ++++++ functions | 6 ++++++ install | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 7858341..5b1c92a 100644 --- a/README.md +++ b/README.md @@ -267,3 +267,9 @@ custom certificate by overwriting the `server.crt` and `server.key` files in `/var/lib/dokku/services/postgres//data`. The `server.key` must be chmoded to 600 and must be owned by the postgres user or root. + +## Disabling `docker pull` calls + +If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `POSTGRES_DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output. + +Please ensure the proper images are in place when `docker pull` is disabled. diff --git a/functions b/functions index a13bc8f..c1f56e9 100755 --- a/functions +++ b/functions @@ -30,6 +30,12 @@ service_create() { service_parse_args "${@:2}" if ! docker images | grep -e "^$PLUGIN_IMAGE " | grep -q " $PLUGIN_IMAGE_VERSION " ; then + if [[ "$POSTGRES_DISABLE_PULL" == "true" ]]; then + dokku_log_warn "POSTGRES_DISABLE_PULL environment variable detected. Not running pull command." 1>&2 + dokku_log_warn " docker pull ${IMAGE}" 1>&2 + dokku_log_warn "$PLUGIN_SERVICE service creation failed" + exit 1 + fi docker pull "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" || dokku_log_fail "$PLUGIN_SERVICE image $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION pull failed" fi diff --git a/install b/install index 57f8833..dbcf005 100755 --- a/install +++ b/install @@ -5,6 +5,11 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x plugin-install() { pull-docker-image() { declare IMAGE="$1" + if [[ "$POSTGRES_DISABLE_PULL" == "true" ]]; then + echo " ! POSTGRES_DISABLE_PULL environment variable detected. Not running pull command." 1>&2 + echo " ! docker pull ${IMAGE}" 1>&2 + return + fi if [[ "$(docker images -q "${IMAGE}" 2> /dev/null)" == "" ]]; then docker pull "${IMAGE}" fi