builder-nixpacks/builder-build

52 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

2022-08-26 16:08:03 -04:00
#!/usr/bin/env bash
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
2022-08-30 10:26:44 -04:00
source "$PLUGIN_AVAILABLE_PATH/builder-nixpacks/internal-functions"
2022-08-26 16:08:03 -04:00
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
trigger-builder-nixpacks-builder-build() {
declare desc="builder-nixpacks builder-build plugin trigger"
declare trigger="builder-build"
declare BUILDER_TYPE="$1" APP="$2" SOURCECODE_WORK_DIR="$3"
if [[ "$BUILDER_TYPE" != "nixpacks" ]]; then
return
fi
dokku_log_info1 "Building $APP with nixpacks"
if ! command -v "nixpacks" &>/dev/null; then
dokku_log_fail "Missing nixpacks, install it"
fi
local IMAGE=$(get_app_image_name "$APP")
pushd "$SOURCECODE_WORK_DIR" &>/dev/null
eval "$(config_export app "$APP" --merged)"
plugn trigger pre-build-nixpacks "$APP" "$SOURCECODE_WORK_DIR"
2022-08-30 11:27:56 -04:00
local NIXPACKS_ARGS=""
local NIXPACKS_FLAGS=$(fn-plugin-property-get-all "builder-nixpacks" "$APP")
for flag in $NIXPACKS_FLAGS ; do
local value="$(fn-plugin-property-get "builder-nixpacks" "$APP" "$flag")"
if [[ -n "$value" ]] ; then
2022-08-30 11:58:38 -04:00
if [[ "$value" =~ " " ]] ; then
2022-08-30 12:12:13 -04:00
NIXPACKS_ARGS="${NIXPACKS_ARGS}--${flag} \"${value}\" "
2022-08-30 11:58:38 -04:00
else
2022-08-30 12:12:13 -04:00
NIXPACKS_ARGS="${NIXPACKS_ARGS}--${flag} ${value} "
2022-08-30 11:58:38 -04:00
fi
2022-08-30 11:27:56 -04:00
fi
2022-08-30 10:26:44 -04:00
done
2022-08-26 16:08:03 -04:00
2022-08-30 11:45:12 -04:00
dokku_log_info1_quiet "nixpacks build . --name $IMAGE $NIXPACKS_ARGS"
nixpacks build . --name "$IMAGE" $NIXPACKS_ARGS
2022-08-26 16:08:03 -04:00
docker-image-labeler --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"
plugn trigger post-build-nixpacks "$APP" "$SOURCECODE_WORK_DIR"
}
trigger-builder-nixpacks-builder-build "$@"