main
Andrew Coleman 2022-08-30 11:27:56 -04:00
parent 97eb7582a0
commit dac338b3bb
3 changed files with 18 additions and 22 deletions

View File

@ -28,14 +28,22 @@ trigger-builder-nixpacks-builder-build() {
plugn trigger pre-build-nixpacks "$APP" "$SOURCECODE_WORK_DIR"
local flag_map=$(fn-plugin-property-get-all "builder-nixpacks" "$APP")
let NIXPACKS_ARGS=""
for flag in ${flag_map[@]} ; do
NIXPACKS_ARGS+="$(echo "${flag}" | tr ' ' '=') "
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
NIXPACKS_ARGS="${NIXPACKS_ARGS}${flag}='${value}' "
fi
done
echo /usr/bin/env "${NIXPACKS_ARGS}" nixpacks build . --name "$IMAGE"
/usr/bin/env "${NIXPACKS_ARGS}" nixpacks build . --name "$IMAGE"
if [[ -n "$NIXPACKS_ARGS" ]] ; then
dokku_info_log2_quiet "nixpacks build . --name $IMAGE --env $NIXPACKS_ARGS"
nixpacks build . --name "$IMAGE" --env "$NIXPACKS_ARGS"
else
dokku_info_log2_quiet "nixpacks build . --name $IMAGE"
nixpacks build . --name "$IMAGE"
fi
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"

View File

@ -34,7 +34,7 @@ cmd-builder-nixpacks-report-single() {
dokku_log_info2_quiet "${APP} builder-nixpacks information"
local NIXPACK_KEYS="$(fn-builder-nixpacks-valid-keys)"
for key in "${NIXPACK_KEYS[@]}" ; do
for key in $NIXPACK_KEYS ; do
local result="$(fn-plugin-property-get "builder-nixpacks" "$APP" "$key")"
dokku_log_verbose "$(printf "%-30s %-40s" "${key}" "${result}")"
done
@ -42,4 +42,4 @@ cmd-builder-nixpacks-report-single() {
fn-builder-nixpacks-valid-keys() {
echo "NIXPACKS_APT_PKGS NIXPACKS_BUILD_CACHE_DIRS NIXPACKS_BUILD_CMD NIXPACKS_INSTALL_CACHE_DIRS NIXPACKS_INSTALL_CMD NIXPACKS_LIBS NIXPACKS_NO_CACHE NIXPACKS_NO_MUSL NIXPACKS_PKGS NIXPACKS_START_CMD"
)
}

View File

@ -11,24 +11,12 @@ cmd-builder-nixpacks-set() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" KEY="$2" VALUE="$3"
local VALID_KEYS=$(fn-builder-nixpacks-valid-keys)
local VALID_KEYS=(\
"NIXPACKS_APT_PKGS" \
"NIXPACKS_BUILD_CACHE_DIRS" \
"NIXPACKS_BUILD_CMD" \
"NIXPACKS_INSTALL_CACHE_DIRS" \
"NIXPACKS_INSTALL_CMD" \
"NIXPACKS_LIBS" \
"NIXPACKS_NO_CACHE" \
"NIXPACKS_NO_MUSL" \
"NIXPACKS_PKGS" \
"NIXPACKS_START_CMD" \
)
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: ${VALID_KEYS[@]}"
if ! is_val_in_list "$KEY" "$VALID_KEYS" " "; then
dokku_log_fail "Invalid key specified, valid keys include: $VALID_KEYS"
fi
if [[ -n "$VALUE" ]]; then