feat: add initial support for cloud native buildpacks
This change adds a new builder - builder-cnb - via the 'DOKKU_CNB_EXPERIMENTAL' environment variable. While support for customizing pack builds is not currently implemented and there may be other missing functionality, this initial implementation allows folks to start playing with CNB. Future releases of Dokku will provide tighter CNB integration and eventually switch to CNB for default building, as well as allow users to better select builders needed for their applications. All new code for CNB support should be considered experimental and subject to change as the support evolves over time.
This commit is contained in:
38
plugins/builder-cnb/builder-build
Executable file
38
plugins/builder-cnb/builder-build
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
trigger-builder-cnb-builder-build() {
|
||||
declare desc="builder-cnb builder-build plugin trigger"
|
||||
declare trigger="builder-build"
|
||||
declare BUILDER_TYPE="$1" APP="$2" SOURCECODE_WORK_DIR="$3"
|
||||
|
||||
if [[ "$BUILDER_TYPE" != "cnb" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if ! command -v "pack" &>/dev/null; then
|
||||
dokku_log_fail "Missing pack, install it"
|
||||
fi
|
||||
|
||||
local IMAGE=$(get_app_image_name "$APP")
|
||||
|
||||
pushd "$SOURCECODE_WORK_DIR" &>/dev/null
|
||||
|
||||
local TMP_FILE=$(mktemp "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX")
|
||||
trap "rm -rf '$TMP_FILE' >/dev/null" RETURN INT TERM
|
||||
|
||||
config_export app "$APP" --format envfile --merged > "$TMP_FILE"
|
||||
|
||||
plugn trigger pre-build-cnb "$APP" "$SOURCECODE_WORK_DIR"
|
||||
|
||||
pack build "$IMAGE" --builder heroku/buildpacks --path "$SOURCECODE_WORK_DIR" --default-process web
|
||||
|
||||
echo "FROM $IMAGE" | suppress_output "$DOCKER_BIN" image build --label=com.dokku.image-stage=build --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=com.dokku.app-name=$APP --label=dokku -t "$IMAGE" -
|
||||
|
||||
plugn trigger post-build-cnb "$APP" "$SOURCECODE_WORK_DIR"
|
||||
}
|
||||
|
||||
trigger-builder-cnb-builder-build "$@"
|
||||
22
plugins/builder-cnb/builder-release
Executable file
22
plugins/builder-cnb/builder-release
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
trigger-builder-cnb-builder-release() {
|
||||
declare desc="builder-cnb builder-release plugin trigger"
|
||||
declare trigger="builder-release"
|
||||
declare BUILDER_TYPE="$1" APP="$2" IMAGE_TAG="$3"
|
||||
|
||||
if [[ "$BUILDER_TYPE" != "cnb" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
plugn trigger pre-release-cnb "$APP" "$IMAGE_TAG"
|
||||
|
||||
local IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG")
|
||||
echo "FROM $IMAGE" | suppress_output "$DOCKER_BIN" image build --label=com.dokku.image-stage=release --label=com.dokku.app-name=$APP --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=dokku -t "$IMAGE" -
|
||||
plugn trigger post-release-cnb "$APP" "$IMAGE_TAG"
|
||||
}
|
||||
|
||||
trigger-builder-cnb-builder-release "$@"
|
||||
4
plugins/builder-cnb/plugin.toml
Normal file
4
plugins/builder-cnb/plugin.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core builder-cnb plugin"
|
||||
version = "0.21.4"
|
||||
[plugin.config]
|
||||
Reference in New Issue
Block a user