From d433614f17c0f5f8cce011cac45b5dc947482e3d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 5 Sep 2016 00:15:39 -0400 Subject: [PATCH] Move deployment tasks to post-deploy hook As deployment tasks can fail due to non-dokku related issues, moving them to post-deploy will ensure that dokku does not accidentally orphan applications. Closes #2367 --- docs/advanced-usage/deployment-tasks.md | 3 ++- docs/development/plugin-triggers.md | 2 +- plugins/00_dokku-standard/core-post-deploy | 11 ----------- plugins/00_dokku-standard/post-deploy | 15 +++++++++++++++ 4 files changed, 18 insertions(+), 13 deletions(-) create mode 100755 plugins/00_dokku-standard/post-deploy diff --git a/docs/advanced-usage/deployment-tasks.md b/docs/advanced-usage/deployment-tasks.md index a4e28366f..ce70d4953 100644 --- a/docs/advanced-usage/deployment-tasks.md +++ b/docs/advanced-usage/deployment-tasks.md @@ -15,7 +15,8 @@ Dokku accomplishes this by using an `app.json` file. The format in use is simila However, Dokku currently only supports the nodes `scripts.dokku.predeploy` and `scripts.dokku.postdeploy`. For buildpack apps, simply place an `app.json` file in the root of your repository. For dockerfile apps, place `app.json` in the configured `WORKDIR` directory; otherwise Dokku defaults to the buildpack app behavior of looking in `/app`. ->NOTE: postdeploy changes are *NOT* committed to the app image. + +> NOTE: postdeploy changes are *NOT* committed to the app image. ### Example app.json diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index 5223ee2f1..846c6fecd 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -450,7 +450,7 @@ dokku postgres:destroy $APP > Please see [core-post-deploy](#core-post-deploy) if contributing a core plugin with the `post-deploy` hook. -- Description: Allows running of commands after an application's processes have been scaled up, but before old containers are torn down. Dokku calls this _after_ `core-post-deploy`. +- Description: Allows running of commands after an application's processes have been scaled up, but before old containers are torn down. Dokku calls this _after_ `core-post-deploy`. Deployment Tasks are also invoked by this plugin trigger. - Invoked by: `dokku deploy` - Arguments: `$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG` - Example: diff --git a/plugins/00_dokku-standard/core-post-deploy b/plugins/00_dokku-standard/core-post-deploy index a020a1efe..7b21978cb 100755 --- a/plugins/00_dokku-standard/core-post-deploy +++ b/plugins/00_dokku-standard/core-post-deploy @@ -1,16 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_CORE_AVAILABLE_PATH/00_dokku-standard/exec-app-json-scripts" - -exec_app_json_scripts() { - declare desc="core app.json scripts execution" - local trigger="core-post-deploy app_json_scripts" - local APP="$1"; local IMAGE_TAG="$4"; local PHASE_SCRIPT_KEY="postdeploy" - - dokku_log_info1 "Attempting to run scripts.dokku.$PHASE_SCRIPT_KEY from app.json (if defined)" - execute_script "$APP" "$IMAGE_TAG" "$PHASE_SCRIPT_KEY" -} cleanup_container_state() { declare desc="core post-deploy state cleanup" @@ -30,5 +20,4 @@ cleanup_container_state() { done } -exec_app_json_scripts "$@" cleanup_container_state "$@" diff --git a/plugins/00_dokku-standard/post-deploy b/plugins/00_dokku-standard/post-deploy new file mode 100755 index 000000000..50603555e --- /dev/null +++ b/plugins/00_dokku-standard/post-deploy @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/00_dokku-standard/exec-app-json-scripts" + +exec_app_json_scripts() { + declare desc="core app.json scripts execution" + local trigger="post-deploy app_json_scripts" + local APP="$1"; local IMAGE_TAG="$4"; local PHASE_SCRIPT_KEY="postdeploy" + + dokku_log_info1 "Attempting to run scripts.dokku.$PHASE_SCRIPT_KEY from app.json (if defined)" + execute_script "$APP" "$IMAGE_TAG" "$PHASE_SCRIPT_KEY" +} + +exec_app_json_scripts "$@"