refactor: move external procfile manipulation into triggers
This also cleans up the internal APIs a bit.
This commit is contained in:
@@ -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
|
||||
|
||||
1
plugins/20_events/procfile-extract
Symbolic link
1
plugins/20_events/procfile-extract
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
1
plugins/20_events/procfile-remove
Symbolic link
1
plugins/20_events/procfile-remove
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
1
plugins/20_events/profile-get-command
Symbolic link
1
plugins/20_events/profile-get-command
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
@@ -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"
|
||||
|
||||
23
plugins/ps/procfile-extract
Executable file
23
plugins/ps/procfile-extract
Executable file
@@ -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 "$@"
|
||||
19
plugins/ps/procfile-get-command
Executable file
19
plugins/ps/procfile-get-command
Executable file
@@ -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 "$@"
|
||||
18
plugins/ps/procfile-remove
Executable file
18
plugins/ps/procfile-remove
Executable file
@@ -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 "$@"
|
||||
Reference in New Issue
Block a user