feat: allow users to enable herokuish usage on arm/arm64 platforms
While the majority of buildpacks do not work on non-amd64 platforms, this will at least allow developers the option to choose when to override this setting.
This commit is contained in:
18
plugins/builder-herokuish/builder-herokuish-allowed
Executable file
18
plugins/builder-herokuish/builder-herokuish-allowed
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/builder-herokuish/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
trigger-builder-herokuish-builder-herokuish-allowed() {
|
||||
declare desc="builder-herokuish builder-herokuish-allowed plugin trigger"
|
||||
declare trigger="builder-herokuish-allowed"
|
||||
declare APP="$1"
|
||||
|
||||
if [[ "$(fn-builder-herokuish-computed-allowed "$APP")" != "true" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
trigger-builder-herokuish-builder-herokuish-allowed "$@"
|
||||
33
plugins/builder-herokuish/help-functions
Executable file
33
plugins/builder-herokuish/help-functions
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-builder-herokuish-help() {
|
||||
declare desc="help command"
|
||||
declare CMD="$1"
|
||||
local plugin_name="builder-herokuish"
|
||||
local plugin_description="Manage the herokuish builder integration for an app"
|
||||
|
||||
if [[ "$CMD" == "${plugin_name}:help" ]]; then
|
||||
echo -e "Usage: dokku ${plugin_name}[:COMMAND]"
|
||||
echo ''
|
||||
echo "$plugin_description"
|
||||
echo ''
|
||||
echo 'Additional commands:'
|
||||
fn-help-content | sort | column -c2 -t -s,
|
||||
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
|
||||
fn-help-content
|
||||
else
|
||||
cat <<help_desc
|
||||
$plugin_name, $plugin_description
|
||||
help_desc
|
||||
fi
|
||||
}
|
||||
|
||||
fn-help-content() {
|
||||
declare desc="return help content"
|
||||
cat <<help_content
|
||||
builder-herokuish:report [<app>] [<flag>], Displays a builder-herokuish report for one or more apps
|
||||
builder-herokuish:set <app> <property> (<value>), Set or clear a builder-herokuish property for an app
|
||||
help_content
|
||||
}
|
||||
92
plugins/builder-herokuish/internal-functions
Executable file
92
plugins/builder-herokuish/internal-functions
Executable file
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-builder-herokuish-report() {
|
||||
declare desc="displays a builder-herokuish report for one or more apps"
|
||||
declare cmd="builder-herokuish:report"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1" INFO_FLAG="$2"
|
||||
|
||||
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
|
||||
INFO_FLAG="$APP"
|
||||
APP=""
|
||||
fi
|
||||
|
||||
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
|
||||
INFO_FLAG="true"
|
||||
fi
|
||||
|
||||
if [[ -z "$APP" ]]; then
|
||||
for app in $(dokku_apps); do
|
||||
cmd-builder-herokuish-report-single "$app" "$INFO_FLAG" | tee || true
|
||||
done
|
||||
else
|
||||
cmd-builder-herokuish-report-single "$APP" "$INFO_FLAG"
|
||||
fi
|
||||
}
|
||||
|
||||
cmd-builder-herokuish-report-single() {
|
||||
declare APP="$1" INFO_FLAG="$2"
|
||||
if [[ "$INFO_FLAG" == "true" ]]; then
|
||||
INFO_FLAG=""
|
||||
fi
|
||||
verify_app_name "$APP"
|
||||
local flag_map=(
|
||||
"--builder-herokuish-computed-allowed: $(fn-builder-herokuish-computed-allowed "$APP")"
|
||||
"--builder-herokuish-global-allowed: $(fn-builder-herokuish-global-allowed)"
|
||||
"--builder-herokuish-allowed: $(fn-builder-herokuish-allowed "$APP")"
|
||||
)
|
||||
|
||||
if [[ -z "$INFO_FLAG" ]]; then
|
||||
dokku_log_info2_quiet "${APP} builder-herokuish information"
|
||||
for flag in "${flag_map[@]}"; do
|
||||
key="$(echo "${flag#--}" | cut -f1 -d' ' | tr - ' ')"
|
||||
dokku_log_verbose "$(printf "%-30s %-25s" "${key^}" "${flag#*: }")"
|
||||
done
|
||||
else
|
||||
local match=false
|
||||
local value_exists=false
|
||||
for flag in "${flag_map[@]}"; do
|
||||
valid_flags="${valid_flags} $(echo "$flag" | cut -d':' -f1)"
|
||||
if [[ "$flag" == "${INFO_FLAG}:"* ]]; then
|
||||
value=${flag#*: }
|
||||
size="${#value}"
|
||||
if [[ "$size" -ne 0 ]]; then
|
||||
echo "$value" && match=true && value_exists=true
|
||||
else
|
||||
match=true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
[[ "$match" == "true" ]] || dokku_log_fail "Invalid flag passed, valid flags:${valid_flags}"
|
||||
[[ "$value_exists" == "true" ]] || dokku_log_fail "not deployed"
|
||||
fi
|
||||
}
|
||||
|
||||
fn-builder-herokuish-computed-allowed() {
|
||||
declare APP="$1"
|
||||
|
||||
allowed="$(fn-builder-herokuish-allowed "$APP")"
|
||||
if [[ -z "$allowed" ]]; then
|
||||
allowed="$(fn-builder-herokuish-global-allowed)"
|
||||
fi
|
||||
|
||||
echo "$allowed"
|
||||
}
|
||||
|
||||
fn-builder-herokuish-global-allowed() {
|
||||
local default_value="true"
|
||||
|
||||
[[ "$(dpkg --print-architecture 2>/dev/null || true)" != "amd64" ]] && default_value="false"
|
||||
|
||||
fn-plugin-property-get-default "builder-herokuish" "--global" "allowed" "$default_value"
|
||||
}
|
||||
|
||||
fn-builder-herokuish-allowed() {
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "builder-herokuish" "$APP" "allowed" ""
|
||||
}
|
||||
6
plugins/builder-herokuish/subcommands/default
Executable file
6
plugins/builder-herokuish/subcommands/default
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/builder-herokuish/help-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-builder-herokuish-help "builder-herokuish:help"
|
||||
6
plugins/builder-herokuish/subcommands/report
Executable file
6
plugins/builder-herokuish/subcommands/report
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/builder-herokuish/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-builder-herokuish-report "$@"
|
||||
30
plugins/builder-herokuish/subcommands/set
Executable file
30
plugins/builder-herokuish/subcommands/set
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-builder-herokuish-set() {
|
||||
declare desc="set or clear a builder-herokuish property for an app"
|
||||
declare cmd="builder-herokuish:set"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1" KEY="$2" VALUE="$3"
|
||||
local VALID_KEYS=("allowed")
|
||||
[[ "$APP" == "--global" ]] || verify_app_name "$APP"
|
||||
|
||||
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
|
||||
|
||||
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
|
||||
dokku_log_fail "Invalid key specified, valid keys include: allowed"
|
||||
fi
|
||||
|
||||
if [[ -n "$VALUE" ]]; then
|
||||
dokku_log_info2_quiet "Setting ${KEY} to ${VALUE}"
|
||||
fn-plugin-property-write "builder-herokuish" "$APP" "$KEY" "$VALUE"
|
||||
else
|
||||
dokku_log_info2_quiet "Unsetting ${KEY}"
|
||||
fn-plugin-property-delete "builder-herokuish" "$APP" "$KEY"
|
||||
fi
|
||||
}
|
||||
|
||||
cmd-builder-herokuish-set "$@"
|
||||
@@ -99,11 +99,11 @@ fn-checks-computed-wait-to-retire() {
|
||||
fn-checks-global-wait-to-retire() {
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get "checks" "--global" "wait-to-retire" "60"
|
||||
fn-plugin-property-get-default "checks" "--global" "wait-to-retire" "60"
|
||||
}
|
||||
|
||||
fn-checks-wait-to-retire() {
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get "checks" "$APP" "wait-to-retire" ""
|
||||
fn-plugin-property-get-default "checks" "$APP" "wait-to-retire" ""
|
||||
}
|
||||
|
||||
@@ -60,15 +60,17 @@ git_trigger_build() {
|
||||
BUILDER="$(plugn trigger builder-detect "$APP" "$TMP_WORK_DIR" | head -n1 || true)"
|
||||
if [[ -z "$BUILDER" ]]; then
|
||||
BUILDER="herokuish"
|
||||
local ARCHITECTURE="$(dpkg --print-architecture 2>/dev/null || true)"
|
||||
if [[ "$ARCHITECTURE" == "arm64" ]]; then
|
||||
dokku_log_warn "Herokuish builder not supported on $ARCHITECTURE servers."
|
||||
dokku_log_warn "Switching to pack builder."
|
||||
BUILDER="pack"
|
||||
elif [[ "$ARCHITECTURE" == "armhf" ]]; then
|
||||
dokku_log_warn "Herokuish builder not supported on $ARCHITECTURE servers."
|
||||
dokku_log_warn "Consider using a Dockerfile to build your app."
|
||||
return 1
|
||||
if ! plugn trigger builder-herokuish-allowed "$APP" >/dev/null; then
|
||||
local ARCHITECTURE="$(dpkg --print-architecture 2>/dev/null || true)"
|
||||
if [[ "$ARCHITECTURE" == "arm64" ]]; then
|
||||
dokku_log_warn "Herokuish builder not supported on $ARCHITECTURE servers."
|
||||
dokku_log_warn "Switching to pack builder."
|
||||
BUILDER="pack"
|
||||
elif [[ "$ARCHITECTURE" == "armhf" ]]; then
|
||||
dokku_log_warn "Herokuish builder not supported on $ARCHITECTURE servers."
|
||||
dokku_log_warn "Consider using a Dockerfile to build your app."
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user