refactor: move external procfile manipulation into triggers
This also cleans up the internal APIs a bit.
This commit is contained in:
1 parent
98bc513336
commit
1ea60a16e5
8 files changed
+130
-5
No files matched your search
@@ -1447,6 +1447,51 @@ APP="$1";
|
|||||||
curl "https://dokku.me/starting/${APP}" || true
|
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`
|
### `proxy-build-config`
|
||||||
|
|
||||||
- Description: Builds the proxy implementation configuration for a given app
|
- Description: Builds the proxy implementation configuration for a given app
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
hook
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
hook
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
hook
|
||||||
+22
-5
@@ -11,8 +11,7 @@ get_cmd_from_procfile() {
|
|||||||
local COMMAND
|
local COMMAND
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
|
|
||||||
[[ ! -f $DOKKU_PROCFILE ]] && return
|
fn-procfile-get-command "$DOKKU_PROCFILE" "$PROC_TYPE" "$PORT"
|
||||||
procfile-util show --procfile "$DOKKU_PROCFILE" --process-type "$PROC_TYPE" --default-port "$PORT"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print_dokku_scale_file() {
|
print_dokku_scale_file() {
|
||||||
@@ -31,11 +30,18 @@ extract_procfile() {
|
|||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
|
|
||||||
remove_procfile "$APP"
|
remove_procfile "$APP"
|
||||||
copy_from_image "$IMAGE" "Procfile" "$DOKKU_PROCFILE" 2>/dev/null || true
|
fn-procfile-extract "$IMAGE" "$DOKKU_PROCFILE"
|
||||||
if [[ -f "$DOKKU_PROCFILE" ]]; then
|
}
|
||||||
|
|
||||||
|
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"
|
dokku_log_info1_quiet "App Procfile file found"
|
||||||
# shellcheck disable=SC2069
|
# 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
|
if [[ -n "$PROCFILE_ERRORS" ]]; then
|
||||||
dokku_log_fail "${PROCFILE_ERRORS}"
|
dokku_log_fail "${PROCFILE_ERRORS}"
|
||||||
fi
|
fi
|
||||||
@@ -44,6 +50,17 @@ extract_procfile() {
|
|||||||
fi
|
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() {
|
remove_procfile() {
|
||||||
declare desc="removes DOKKU_PROCFILE"
|
declare desc="removes DOKKU_PROCFILE"
|
||||||
local APP="$1"
|
local APP="$1"
|
||||||
|
|||||||
Executable
+23
@@ -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 "$@"
|
||||||
Executable
+19
@@ -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 "$@"
|
||||||
Executable
+18
@@ -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