feat: split stack property into per-builder properties
The `stack` property lived on the `buildpacks` plugin but was shared by both the herokuish and pack builders, so a value valid for one builder broke the other. Each builder now owns its own `stack` property managed via `builder-herokuish:set` and `builder-pack:set`, while `buildpacks:set-property stack` is deprecated and forwards the value to the builder detected from it; existing values migrate automatically on upgrade and changing a builder's stack clears that builder's cache.
This commit is contained in:
23 files changed
+449
-178
No files matched your search
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/builder-pack/internal-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
@@ -13,7 +14,8 @@ trigger-builder-pack-builder-build() {
|
||||
return
|
||||
fi
|
||||
|
||||
local stack="$(plugn trigger buildpack-stack-name "$APP")"
|
||||
local stack="$(fn-builder-pack-stack "$APP")"
|
||||
[[ -z "$stack" ]] && stack="$(fn-builder-pack-global-stack "$APP")"
|
||||
if [[ -n "$stack" ]]; then
|
||||
DOKKU_CNB_BUILDER="$stack"
|
||||
fi
|
||||
@@ -303,6 +305,10 @@ trigger-builder-pack-builder-build() {
|
||||
local DOCKER_CONFIG
|
||||
DOCKER_CONFIG="$(fn-registry-docker-config-dir "$APP")"
|
||||
[[ -n "$DOCKER_CONFIG" ]] && export DOCKER_CONFIG
|
||||
if [[ "$(fn-plugin-property-get-default "builder-pack" "$APP" "clear-cache" "false")" == "true" ]]; then
|
||||
fn-in-array "--clear-cache" "${PACK_ARGS[@]}" || PACK_ARGS+=("--clear-cache")
|
||||
fn-plugin-property-delete "builder-pack" "$APP" "clear-cache"
|
||||
fi
|
||||
pack build "$IMAGE" --builder "$DOKKU_CNB_BUILDER" --path "$SOURCECODE_WORK_DIR" --default-process web "${PACK_ARGS[@]}" "${ENV_ARGS[@]}"
|
||||
docker-image-labeler relabel --label=dokku --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=com.dokku.image-stage=build --label=com.dokku.builder-type=pack --label=com.dokku.app-name=$APP "$IMAGE"
|
||||
|
||||
|
||||
@@ -29,3 +29,29 @@ fn-builder-pack-projecttoml-path() {
|
||||
|
||||
fn-plugin-property-get-default "builder-pack" "$APP" "projecttoml-path" ""
|
||||
}
|
||||
|
||||
fn-builder-pack-computed-stack() {
|
||||
declare APP="$1"
|
||||
|
||||
stack="$(fn-builder-pack-stack "$APP")"
|
||||
if [[ "$stack" == "" ]]; then
|
||||
stack="$(fn-builder-pack-global-stack "$APP")"
|
||||
fi
|
||||
if [[ "$stack" == "" ]]; then
|
||||
stack="${DOKKU_CNB_BUILDER:-heroku/builder:24}"
|
||||
fi
|
||||
|
||||
echo "$stack"
|
||||
}
|
||||
|
||||
fn-builder-pack-global-stack() {
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "builder-pack" "--global" "stack" ""
|
||||
}
|
||||
|
||||
fn-builder-pack-stack() {
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "builder-pack" "$APP" "stack" ""
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package builderpack
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
@@ -17,12 +19,17 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
|
||||
flags = map[string]common.ReportFunc{
|
||||
"--builder-pack-computed-projecttoml-path": reportComputedProjecttomlPath,
|
||||
"--builder-pack-global-projecttoml-path": reportGlobalProjecttomlPath,
|
||||
"--builder-pack-computed-stack": reportComputedStack,
|
||||
"--builder-pack-global-stack": reportGlobalStack,
|
||||
}
|
||||
} else {
|
||||
flags = map[string]common.ReportFunc{
|
||||
"--builder-pack-computed-projecttoml-path": reportComputedProjecttomlPath,
|
||||
"--builder-pack-global-projecttoml-path": reportGlobalProjecttomlPath,
|
||||
"--builder-pack-projecttoml-path": reportProjecttomlPath,
|
||||
"--builder-pack-computed-stack": reportComputedStack,
|
||||
"--builder-pack-global-stack": reportGlobalStack,
|
||||
"--builder-pack-stack": reportStack,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,3 +71,26 @@ func reportComputedProjecttomlPath(appName string) string {
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func reportStack(appName string) string {
|
||||
return common.PropertyGet("builder-pack", appName, "stack")
|
||||
}
|
||||
|
||||
func reportGlobalStack(appName string) string {
|
||||
return common.PropertyGet("builder-pack", "--global", "stack")
|
||||
}
|
||||
|
||||
func reportComputedStack(appName string) string {
|
||||
value := reportStack(appName)
|
||||
if value == "" {
|
||||
value = reportGlobalStack(appName)
|
||||
}
|
||||
if value == "" {
|
||||
value = os.Getenv("DOKKU_CNB_BUILDER")
|
||||
}
|
||||
if value == "" {
|
||||
value = "heroku/builder:24"
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
@@ -9,13 +9,13 @@ cmd-builder-pack-set() {
|
||||
declare cmd="builder-pack:set"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1" KEY="$2" VALUE="$3"
|
||||
local VALID_KEYS=("projecttoml-path")
|
||||
local VALID_KEYS=("projecttoml-path" "stack")
|
||||
[[ "$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: projecttoml-path"
|
||||
dokku_log_fail "Invalid key specified, valid keys include: projecttoml-path, stack"
|
||||
fi
|
||||
|
||||
if [[ -n "$VALUE" ]]; then
|
||||
@@ -25,6 +25,14 @@ cmd-builder-pack-set() {
|
||||
dokku_log_info2_quiet "Unsetting ${KEY}"
|
||||
fn-plugin-property-delete "builder-pack" "$APP" "$KEY"
|
||||
fi
|
||||
|
||||
if [[ "$KEY" == "stack" ]]; then
|
||||
if [[ "$APP" == "--global" ]]; then
|
||||
for app in $(dokku_apps 2>/dev/null || true); do fn-plugin-property-write "builder-pack" "$app" "clear-cache" "true"; done
|
||||
else
|
||||
fn-plugin-property-write "builder-pack" "$APP" "clear-cache" "true"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
cmd-builder-pack-set "$@"
|
||||
Reference in new issue
Block a user