diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index 05dd41e2b..660b0696e 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -1447,6 +1447,51 @@ APP="$1"; curl "https://dokku.me/starting/${APP}" || true ``` +### `procfile-extract` + +- Description: Extracts a Procfile from a given image to a path +- Invoked by: `internally` +- Arguments: `$APP $IMAGE $FORCE_EXTRACT $PROCFILE_PATH` +- Example: + +```shell +#!/usr/bin/env bash + +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +# TODO +``` + +### `procfile-get-command` + +- Description: Fetches the command for a specific process type +- Invoked by: `internally` +- Arguments: `$APP $PROCESS_TYPE $PORT $PROCFILE_PATH` +- Example: + +```shell +#!/usr/bin/env bash + +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +# TODO +``` + +### `procfile-remove` + +- Description: Removes the extracted Procfile +- Invoked by: `internally` +- Arguments: `$APP $PROCFILE_PATH` +- Example: + +```shell +#!/usr/bin/env bash + +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +# TODO +``` + ### `proxy-build-config` - Description: Builds the proxy implementation configuration for a given app diff --git a/plugins/20_events/procfile-extract b/plugins/20_events/procfile-extract new file mode 120000 index 000000000..5178a749f --- /dev/null +++ b/plugins/20_events/procfile-extract @@ -0,0 +1 @@ +hook \ No newline at end of file diff --git a/plugins/20_events/procfile-remove b/plugins/20_events/procfile-remove new file mode 120000 index 000000000..5178a749f --- /dev/null +++ b/plugins/20_events/procfile-remove @@ -0,0 +1 @@ +hook \ No newline at end of file diff --git a/plugins/20_events/profile-get-command b/plugins/20_events/profile-get-command new file mode 120000 index 000000000..5178a749f --- /dev/null +++ b/plugins/20_events/profile-get-command @@ -0,0 +1 @@ +hook \ No newline at end of file diff --git a/plugins/ps/functions b/plugins/ps/functions index 9a53b57de..46a0cf74f 100755 --- a/plugins/ps/functions +++ b/plugins/ps/functions @@ -11,8 +11,7 @@ get_cmd_from_procfile() { local COMMAND verify_app_name "$APP" - [[ ! -f $DOKKU_PROCFILE ]] && return - procfile-util show --procfile "$DOKKU_PROCFILE" --process-type "$PROC_TYPE" --default-port "$PORT" + fn-procfile-get-command "$DOKKU_PROCFILE" "$PROC_TYPE" "$PORT" } print_dokku_scale_file() { @@ -31,11 +30,18 @@ extract_procfile() { verify_app_name "$APP" remove_procfile "$APP" - copy_from_image "$IMAGE" "Procfile" "$DOKKU_PROCFILE" 2>/dev/null || true - if [[ -f "$DOKKU_PROCFILE" ]]; then + fn-procfile-extract "$IMAGE" "$DOKKU_PROCFILE" +} + +fn-procfile-extract() { + declare desc="extract procfile from a specified docker image" + declare IMAGE="$1" PROCFILE_PATH="$2" + + copy_from_image "$IMAGE" "Procfile" "$PROCFILE_PATH" 2>/dev/null || true + if [[ -f "$PROCFILE_PATH" ]]; then dokku_log_info1_quiet "App Procfile file found" # shellcheck disable=SC2069 - PROCFILE_ERRORS="$(procfile-util check --procfile "$DOKKU_PROCFILE" 2>&1 >/dev/null || true)" + PROCFILE_ERRORS="$(procfile-util check --procfile "$PROCFILE_PATH" 2>&1 >/dev/null || true)" if [[ -n "$PROCFILE_ERRORS" ]]; then dokku_log_fail "${PROCFILE_ERRORS}" fi @@ -44,6 +50,17 @@ extract_procfile() { fi } +fn-procfile-get-command() { + declare desc="Fetch a command from a Procfile" + declare PROCFILE_PATH="$1" PROCESS_TYPE="$2" PORT="$3" + + if [[ ! -f "$PROCFILE_PATH" ]]; then + return + fi + + procfile-util show --procfile "$PROCFILE_PATH" --process-type "$PROCESS_TYPE" --default-port "$PORT" +} + remove_procfile() { declare desc="removes DOKKU_PROCFILE" local APP="$1" diff --git a/plugins/ps/procfile-extract b/plugins/ps/procfile-extract new file mode 100755 index 000000000..5757705b6 --- /dev/null +++ b/plugins/ps/procfile-extract @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_AVAILABLE_PATH/ps/functions" + +trigger-ps-procfile-extract() { + declare desc="ps procfile-extract plugin trigger" + declare trigger="procfile-extract" + declare desc="extract procfile from a specified docker image" + declare APP="$1" IMAGE="$2" FORCE_EXTRACT="$3" PROCFILE_PATH="$4" + + if [[ -z "$PROCFILE_PATH" ]]; then + PROCFILE_PATH="$DOKKU_LIB_ROOT/data/ps/$APP/Procfile.extracted" + fi + + if [[ "$FORCE_EXTRACT" == "true" ]]; then + rm "$PROCFILE_PATH" + fi + + fn-procfile-extract "$APP" "$IMAGE" "$PROCFILE_PATH" +} + +trigger-ps-procfile-extract "$@" diff --git a/plugins/ps/procfile-get-command b/plugins/ps/procfile-get-command new file mode 100755 index 000000000..635f0838f --- /dev/null +++ b/plugins/ps/procfile-get-command @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_AVAILABLE_PATH/ps/functions" + +trigger-ps-procfile-get-command() { + declare desc="ps procfile-get-command plugin trigger" + declare trigger="procfile-get-command" + declare desc="extract command from an app procfile" + declare APP="$1" PROCESS_TYPE="$2" PORT="$3" "$PROCFILE_PATH" + + if [[ -z "$PROCFILE_PATH" ]]; then + PROCFILE_PATH="$DOKKU_LIB_ROOT/data/ps/$APP/Procfile.extracted" + fi + + fn-procfile-get-command "$PROCFILE_PATH" "$PROCESS_TYPE" "$PORT" +} + +trigger-ps-procfile-get-command "$@" diff --git a/plugins/ps/procfile-remove b/plugins/ps/procfile-remove new file mode 100755 index 000000000..2d2f8373a --- /dev/null +++ b/plugins/ps/procfile-remove @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +trigger-ps-procfile-remove() { + declare desc="ps procfile-remove plugin trigger" + declare trigger="procfile-remove" + declare desc="remove procfile for a given app" + declare APP="$1" PROCFILE_PATH="$2" + + if [[ -z "$PROCFILE_PATH" ]]; then + PROCFILE_PATH="$DOKKU_LIB_ROOT/data/ps/$APP/Procfile.extracted" + fi + + rm "$PROCFILE_PATH" +} + +trigger-ps-procfile-remove "$@"