2025-09-08 04:28:05 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
|
|
|
source "$PLUGIN_AVAILABLE_PATH/builder-railpack/internal-functions"
|
|
|
|
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
|
|
|
|
set -eo pipefail
|
|
|
|
|
[[ $DOKKU_TRACE ]] && set -x
|
|
|
|
|
|
|
|
|
|
trigger-builder-railpack-builder-build() {
|
|
|
|
|
declare desc="builder-railpack builder-build plugin trigger"
|
|
|
|
|
declare trigger="builder-build"
|
|
|
|
|
declare BUILDER_TYPE="$1" APP="$2" SOURCECODE_WORK_DIR="$3"
|
|
|
|
|
|
|
|
|
|
if [[ "$BUILDER_TYPE" != "railpack" ]]; then
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
dokku_log_info1 "Building $APP from railpack"
|
|
|
|
|
|
|
|
|
|
if ! command -v "railpack" &>/dev/null; then
|
|
|
|
|
dokku_log_fail "Missing railpack, install it"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local IMAGE=$(get_app_image_name "$APP")
|
|
|
|
|
local DOCKER_BUILD_LABEL_ARGS=("--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=railpack" "--label=com.dokku.app-name=$APP")
|
|
|
|
|
|
|
|
|
|
pushd "$SOURCECODE_WORK_DIR" &>/dev/null
|
|
|
|
|
|
|
|
|
|
plugn trigger pre-build "$BUILDER_TYPE" "$APP" "$SOURCECODE_WORK_DIR"
|
|
|
|
|
|
2025-11-15 22:59:12 -05:00
|
|
|
if [[ -f "$SOURCECODE_WORK_DIR/Procfile" ]]; then
|
|
|
|
|
if procfile-util exists --process-type release; then
|
|
|
|
|
procfile-util delete --process-type release
|
|
|
|
|
fi
|
2025-09-08 04:28:05 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local DOCKER_ARGS=$(: | plugn trigger docker-args-build "$APP" "$BUILDER_TYPE")
|
|
|
|
|
DOCKER_ARGS+=$(: | plugn trigger docker-args-process-build "$APP" "$BUILDER_TYPE")
|
2025-11-15 22:59:12 -05:00
|
|
|
|
|
|
|
|
DOCKER_ARGS=" $DOCKER_ARGS "
|
|
|
|
|
eval set -- "$DOCKER_ARGS"
|
|
|
|
|
|
|
|
|
|
declare -a RAILPACK_ARGS
|
|
|
|
|
while true; do
|
|
|
|
|
case "$1" in
|
|
|
|
|
--platform)
|
|
|
|
|
RAILPACK_ARGS+=("--platform")
|
|
|
|
|
RAILPACK_ARGS+=("$2")
|
|
|
|
|
shift 2
|
|
|
|
|
;;
|
|
|
|
|
--platform=*)
|
2025-11-15 23:13:57 -05:00
|
|
|
RAILPACK_ARGS+=("--platform" "${1#--platform=}")
|
2025-11-15 22:59:12 -05:00
|
|
|
shift 1
|
|
|
|
|
;;
|
|
|
|
|
--progress)
|
|
|
|
|
RAILPACK_ARGS+=("--progress")
|
|
|
|
|
RAILPACK_ARGS+=("$2")
|
|
|
|
|
shift 2
|
|
|
|
|
;;
|
|
|
|
|
--progress=*)
|
2025-11-15 23:13:57 -05:00
|
|
|
RAILPACK_ARGS+=("--progress" "${1#--progress=}")
|
2025-11-15 22:59:12 -05:00
|
|
|
shift 1
|
|
|
|
|
;;
|
|
|
|
|
--cache-key)
|
|
|
|
|
RAILPACK_ARGS+=("--cache-key")
|
|
|
|
|
RAILPACK_ARGS+=("$2")
|
|
|
|
|
shift 2
|
|
|
|
|
;;
|
|
|
|
|
--cache-key=*)
|
2025-11-15 23:13:57 -05:00
|
|
|
RAILPACK_ARGS+=("--cache-key" "${1#--cache-key=}")
|
2025-11-15 22:59:12 -05:00
|
|
|
shift 1
|
|
|
|
|
;;
|
|
|
|
|
-e | --env)
|
|
|
|
|
RAILPACK_ARGS+=("--env")
|
|
|
|
|
RAILPACK_ARGS+=("$2")
|
|
|
|
|
shift 2
|
|
|
|
|
;;
|
|
|
|
|
-e=* | --env=*)
|
|
|
|
|
if [[ "$1" == "--env=*" ]]; then
|
|
|
|
|
RAILPACK_ARGS+=("--env" "${1#--env=}")
|
2025-11-15 23:13:57 -05:00
|
|
|
elif [[ "$1" == "--e=*" ]]; then
|
|
|
|
|
RAILPACK_ARGS+=("--env" "${1#-e=}")
|
2025-11-15 22:59:12 -05:00
|
|
|
fi
|
|
|
|
|
shift 1
|
|
|
|
|
;;
|
|
|
|
|
--previous)
|
|
|
|
|
RAILPACK_ARGS+=("--previous")
|
|
|
|
|
RAILPACK_ARGS+=("$2")
|
|
|
|
|
shift 2
|
|
|
|
|
;;
|
|
|
|
|
--previous=*)
|
2025-11-15 23:13:57 -05:00
|
|
|
RAILPACK_ARGS+=("--previous" "${1#--previous=}")
|
2025-11-15 22:59:12 -05:00
|
|
|
shift 1
|
|
|
|
|
;;
|
|
|
|
|
--build-cmd)
|
|
|
|
|
RAILPACK_ARGS+=("--build-cmd")
|
|
|
|
|
RAILPACK_ARGS+=("$2")
|
|
|
|
|
shift 2
|
|
|
|
|
;;
|
|
|
|
|
--build-cmd=*)
|
2025-11-15 23:13:57 -05:00
|
|
|
RAILPACK_ARGS+=("--build-cmd" "${1#--build-cmd=}")
|
2025-11-15 22:59:12 -05:00
|
|
|
shift 1
|
|
|
|
|
;;
|
|
|
|
|
--start-cmd)
|
|
|
|
|
RAILPACK_ARGS+=("--start-cmd")
|
|
|
|
|
RAILPACK_ARGS+=("$2")
|
|
|
|
|
shift 2
|
|
|
|
|
;;
|
|
|
|
|
--start-cmd=*)
|
2025-11-15 23:13:57 -05:00
|
|
|
RAILPACK_ARGS+=("--start-cmd" "${1#--start-cmd=}")
|
2025-11-15 22:59:12 -05:00
|
|
|
shift 1
|
|
|
|
|
;;
|
|
|
|
|
---show-plan | --error-missing-start)
|
|
|
|
|
RAILPACK_ARGS+=("$1")
|
|
|
|
|
shift 1
|
|
|
|
|
;;
|
|
|
|
|
*)
|
2025-11-16 01:24:28 -05:00
|
|
|
if [[ -n "$1" ]]; then
|
|
|
|
|
shift
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
break
|
2025-11-15 22:59:12 -05:00
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
2025-09-08 04:28:05 -04:00
|
|
|
|
|
|
|
|
eval "$(config_export app "$APP" --merged)"
|
|
|
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
2025-11-15 22:59:12 -05:00
|
|
|
if ! railpack build "${RAILPACK_ARGS[@]}" --name "$IMAGE-build" "$SOURCECODE_WORK_DIR"; then
|
2025-09-08 04:28:05 -04:00
|
|
|
dokku_log_warn "Failure building image"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
2025-09-16 22:09:07 -04:00
|
|
|
if ! suppress_output "$DOCKER_BIN" image build -f "$PLUGIN_AVAILABLE_PATH/builder-railpack/dockerfiles/builder-build.Dockerfile" --build-arg APP_IMAGE="$IMAGE-build" "${DOCKER_BUILD_LABEL_ARGS[@]}" $DOKKU_GLOBAL_BUILD_ARGS -t "$IMAGE" "$SOURCECODE_WORK_DIR"; then
|
|
|
|
|
"$DOCKER_BIN" image remove "$IMAGE-build"
|
2025-09-08 04:28:05 -04:00
|
|
|
dokku_log_warn "Failure injecting docker labels and custom entrypoint on image"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
2025-09-16 22:09:07 -04:00
|
|
|
"$DOCKER_BIN" image remove "$IMAGE-build"
|
|
|
|
|
|
2025-09-08 04:28:05 -04:00
|
|
|
plugn trigger post-build "$BUILDER_TYPE" "$APP" "$SOURCECODE_WORK_DIR"
|
|
|
|
|
popd &>/dev/null || pushd "/tmp" >/dev/null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trigger-builder-railpack-builder-build "$@"
|