mirror of
https://github.com/dokku/dokku.git
synced 2026-05-18 05:05:46 +02:00
Move post-deploy trigger to core-post-deploy. Refs #2367
This avoids issues where community plugins may break core commands because of issues in the command output.
This commit is contained in:
@@ -134,6 +134,24 @@ help_content
|
||||
esac
|
||||
```
|
||||
|
||||
### `core-post-deploy`
|
||||
|
||||
> To avoid issues with community plugins, this plugin trigger should be used *only* for core plugins. Please avoid using this trigger in your own plugins.
|
||||
|
||||
- Description: Allows running of commands after an application's processes have been scaled up, but before old containers are torn down. Dokku core currently uses this to switch traffic on nginx.
|
||||
- Invoked by: `dokku deploy`
|
||||
- Arguments: `$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
#!/usr/bin/env bash
|
||||
# Notify an external service that a successful deploy has occurred.
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
curl "http://httpstat.us/200"
|
||||
```
|
||||
|
||||
### `dependencies`
|
||||
|
||||
- Description: Used to install system-level dependencies. Invoked by `plugin:install-dependencies`.
|
||||
@@ -430,7 +448,9 @@ dokku postgres:destroy $APP
|
||||
|
||||
### `post-deploy`
|
||||
|
||||
- Description: Allows running of commands after an application's processes have been scaled up, but before old containers are torn down. Dokku core currently uses this to switch traffic on nginx.
|
||||
> 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`.
|
||||
- Invoked by: `dokku deploy`
|
||||
- Arguments: `$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG`
|
||||
- Example:
|
||||
|
||||
@@ -5,7 +5,7 @@ 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="pre-deploy app_json_scripts"
|
||||
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)"
|
||||
@@ -14,7 +14,7 @@ exec_app_json_scripts() {
|
||||
|
||||
cleanup_container_state() {
|
||||
declare desc="core post-deploy state cleanup"
|
||||
local trigger="post-deploy cleanup_container_state"
|
||||
local trigger="core-post-deploy cleanup_container_state"
|
||||
local APP="$1"; local PROCTYPES="$(egrep -v "^#" "$DOKKU_ROOT/$APP/DOKKU_SCALE" | awk -F '=' '{ print $1 }' | xargs)"
|
||||
local CONTAINER_FILES="$(find "$DOKKU_ROOT/$APP" -maxdepth 1 -name "CONTAINER.*" -printf "%f\n" 2>/dev/null | sort -t . -k 3 -n | xargs)"
|
||||
|
||||
1
plugins/20_events/core-post-deploy
Symbolic link
1
plugins/20_events/core-post-deploy
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
@@ -646,6 +646,7 @@ dokku_deploy_cmd() {
|
||||
done < "$DOKKU_SCALE_FILE"
|
||||
|
||||
dokku_log_info1 "Running post-deploy"
|
||||
plugn trigger core-post-deploy "$APP" "$port" "$ipaddr" "$IMAGE_TAG"
|
||||
plugn trigger post-deploy "$APP" "$port" "$ipaddr" "$IMAGE_TAG"
|
||||
|
||||
# kill the old container
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
named_containers_post_deploy() {
|
||||
named_containers_core_post_deploy() {
|
||||
declare desc="names deployed app container is consistent manner"
|
||||
local trigger="named_containers_post_deploy"
|
||||
local trigger="named_containers_core_post_deploy"
|
||||
local APP="$1"; local APP_ROOT="$DOKKU_ROOT/$APP"
|
||||
local container
|
||||
|
||||
@@ -38,4 +38,4 @@ named_containers_post_deploy() {
|
||||
shopt -u nullglob
|
||||
}
|
||||
|
||||
named_containers_post_deploy "$@"
|
||||
named_containers_core_post_deploy "$@"
|
||||
@@ -5,9 +5,9 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
|
||||
|
||||
nginx_post_deploy() {
|
||||
declare desc="nginx-vhosts post-deploy plugin trigger"
|
||||
local trigger="nginx_post_deploy"
|
||||
nginx_core_post_deploy() {
|
||||
declare desc="nginx-vhosts core-post-deploy plugin trigger"
|
||||
local trigger="nginx_core_post_deploy"
|
||||
local APP="$1"
|
||||
if [[ -f "$DOKKU_ROOT/$APP/IP.web.1" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT.web.1" ]]; then
|
||||
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
|
||||
@@ -21,5 +21,5 @@ nginx_post_deploy() {
|
||||
}
|
||||
|
||||
if [[ "$(get_app_proxy_type "$1")" == "nginx" ]]; then
|
||||
nginx_post_deploy "$@"
|
||||
nginx_core_post_deploy "$@"
|
||||
fi
|
||||
@@ -4,13 +4,13 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
||||
|
||||
ps_post_deploy() {
|
||||
declare desc="ps post-deploy plugin trigger"
|
||||
local trigger="ps_post_deploy"
|
||||
ps_core_post_deploy() {
|
||||
declare desc="ps core-post-deploy plugin trigger"
|
||||
local trigger="ps_core_post_deploy"
|
||||
local APP="$1"
|
||||
|
||||
remove_procfile "$APP"
|
||||
config_set --no-restart "$APP" DOKKU_APP_RESTORE=1
|
||||
}
|
||||
|
||||
ps_post_deploy "$@"
|
||||
ps_core_post_deploy "$@"
|
||||
Reference in New Issue
Block a user