Files
dokku/plugins/builder-herokuish/functions
Jose Diaz-Gonzalez 353438dbd3 feat: allow builders to be detected based on repository contents
Rather than hardcode two builders, allow builders to specify a `builder-detect` trigger. This trigger can be used to specify if the builder should or should not be used for an application. Each builder takes stdin and can decide if it wants to emit it or emit it's own image source type.

If the final value is empty, then Dokku will default to herokuish (and cnb once that is stable). In addition, a future change may allow users to manually specify a builder in the case they wish to override the choice selected by Dokku.

This change enables users to build custom builder plugins and have those plugins used for building an image asset. By way of example, an enterprising user could create a `builder-lambda` based on lambci, and then pair this with a scheduler plugin that updates a lambda function on AWS. Alternatively, a user might decide they wish to place their Dockerfile in a specific directory for their applications - such as an `_infrastructure` directory - and create a plugin to override how that is detected within Dokku.
2021-02-28 16:19:41 -05:00

39 lines
634 B
Bash
Executable File

#!/usr/bin/env bash
source "$PLUGIN_AVAILABLE_PATH/config/functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
fn-has-buildpacks-file() {
declare SOURCECODE_WORK_DIR="$1"
if [[ -f "$SOURCECODE_WORK_DIR/.buildpacks" ]]; then
return 0
fi
return 1
}
fn-has-buildpack-dotenv() {
declare SOURCECODE_WORK_DIR="$1"
if [[ ! -f "$SOURCECODE_WORK_DIR/.env" ]]; then
return 1
fi
if grep -q BUILDPACK_URL "$SOURCECODE_WORK_DIR/.env"; then
return 0
fi
return 1
}
fn-has-buildpack-env() {
declare APP="$1"
if [[ -n $(config_get "$APP" BUILDPACK_URL || true) ]]; then
return 0
fi
return 1
}