mirror of
https://github.com/dokku/dokku.git
synced 2026-07-11 13:01:51 +02:00
Emitting the restart policy as a `--restart` argument from a `docker-args-process-deploy` trigger exposed a latent gluing bug: proxy and builder triggers concatenated `$STDIN$output` with no separator, and the scheduler and builders appended `docker-args-process-*` output directly onto the older `docker-args-*` output, so adjacent arguments could merge into values like `--restart=on-failure:10--label`. A space is now inserted at both the trigger echo and the concatenation so arguments always stay separated.
294 lines
7.9 KiB
Bash
Executable File
294 lines
7.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
|
source "$PLUGIN_AVAILABLE_PATH/builder-dockerfile/internal-functions"
|
|
set -eo pipefail
|
|
[[ $DOKKU_TRACE ]] && set -x
|
|
|
|
trigger-builder-dockerfile-builder-build() {
|
|
declare desc="builder-dockerfile builder-build plugin trigger"
|
|
declare trigger="builder-build"
|
|
declare BUILDER_TYPE="$1" APP="$2" SOURCECODE_WORK_DIR="$3"
|
|
|
|
if [[ "$BUILDER_TYPE" != "dockerfile" ]]; then
|
|
return
|
|
fi
|
|
|
|
dokku_log_info1 "Building $APP from Dockerfile"
|
|
|
|
local IMAGE=$(get_app_image_name "$APP")
|
|
local DOCKER_BUILD_LABEL_ARGS=("--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=dockerfile" "--label=com.dokku.app-name=$APP" "--label=dokku")
|
|
|
|
pushd "$SOURCECODE_WORK_DIR" &>/dev/null
|
|
|
|
if [[ ! -f "$SOURCECODE_WORK_DIR/Dockerfile" ]]; then
|
|
dokku_log_fail "No Dockerfile found in source code directory"
|
|
return 1
|
|
fi
|
|
|
|
if fn-plugn-trigger-exists "pre-build-dockerfile"; then
|
|
dokku_log_warn "Deprecated: please upgrade plugin to use 'pre-build' plugin trigger instead of pre-build-dockerfile"
|
|
plugn trigger pre-build-dockerfile "$APP"
|
|
fi
|
|
plugn trigger pre-build "$BUILDER_TYPE" "$APP" "$SOURCECODE_WORK_DIR"
|
|
|
|
local DOCKER_ARGS=$(: | plugn trigger docker-args-build "$APP" "$BUILDER_TYPE")
|
|
DOCKER_ARGS+=" $(: | plugn trigger docker-args-process-build "$APP" "$BUILDER_TYPE")"
|
|
DOCKER_ARGS+=" $DOKKU_GLOBAL_BUILD_ARGS"
|
|
|
|
DOCKER_ARGS=" $DOCKER_ARGS "
|
|
eval set -- "$DOCKER_ARGS"
|
|
|
|
declare -a DOCKERFILE_ARGS
|
|
while true; do
|
|
case "$1" in
|
|
--add-host)
|
|
DOCKERFILE_ARGS+=("--add-host")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--add-host=*)
|
|
DOCKERFILE_ARGS+=("--add-host" "${1#--add-host=}")
|
|
shift 1
|
|
;;
|
|
--allow)
|
|
DOCKERFILE_ARGS+=("--allow")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--allow=*)
|
|
DOCKERFILE_ARGS+=("--allow" "${1#--allow=}")
|
|
shift 1
|
|
;;
|
|
--annotation)
|
|
DOCKERFILE_ARGS+=("--annotation")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--annotation=*)
|
|
DOCKERFILE_ARGS+=("--annotation" "${1#--annotation=}")
|
|
shift 1
|
|
;;
|
|
--attest)
|
|
DOCKERFILE_ARGS+=("--attest")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--attest=*)
|
|
DOCKERFILE_ARGS+=("--attest" "${1#--attest=}")
|
|
shift 1
|
|
;;
|
|
--build-arg)
|
|
DOCKERFILE_ARGS+=("--build-arg")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--build-arg=*)
|
|
DOCKERFILE_ARGS+=("--build-arg" "${1#--build-arg=}")
|
|
shift 1
|
|
;;
|
|
--builder)
|
|
DOCKERFILE_ARGS+=("--builder")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--builder=*)
|
|
DOCKERFILE_ARGS+=("--builder" "${1#--builder=}")
|
|
shift 1
|
|
;;
|
|
--cache-from)
|
|
DOCKERFILE_ARGS+=("--cache-from")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--cache-from=*)
|
|
DOCKERFILE_ARGS+=("--cache-from" "${1#--cache-from=}")
|
|
shift 1
|
|
;;
|
|
--cache-to)
|
|
DOCKERFILE_ARGS+=("--cache-to")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--cache-to=*)
|
|
DOCKERFILE_ARGS+=("--cache-to" "${1#--cache-to=}")
|
|
shift 1
|
|
;;
|
|
--call)
|
|
DOCKERFILE_ARGS+=("--call")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--call=*)
|
|
DOCKERFILE_ARGS+=("--call" "${1#--call=}")
|
|
shift 1
|
|
;;
|
|
--cgroup-parent)
|
|
DOCKERFILE_ARGS+=("--cgroup-parent")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--cgroup-parent=*)
|
|
DOCKERFILE_ARGS+=("--cgroup-parent" "${1#--cgroup-parent=}")
|
|
shift 1
|
|
;;
|
|
--label)
|
|
DOCKERFILE_ARGS+=("--label")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--label=*)
|
|
DOCKERFILE_ARGS+=("--label" "${1#--label=}")
|
|
shift 1
|
|
;;
|
|
--memory | -m)
|
|
DOCKERFILE_ARGS+=("--memory")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--memory=* | -m=*)
|
|
if [[ "$1" == "--memory=*" ]]; then
|
|
DOCKERFILE_ARGS+=("--memory" "${1#--memory=}")
|
|
elif [[ "$1" == "-m=*" ]]; then
|
|
DOCKERFILE_ARGS+=("--memory" "${1#-m=}")
|
|
fi
|
|
shift 1
|
|
;;
|
|
--memory-swap)
|
|
DOCKERFILE_ARGS+=("--memory-swap")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--memory-swap=*)
|
|
DOCKERFILE_ARGS+=("--memory-swap" "${1#--memory-swap=}")
|
|
shift 1
|
|
;;
|
|
--network)
|
|
DOCKERFILE_ARGS+=("--network")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--network=*)
|
|
DOCKERFILE_ARGS+=("--network" "${1#--network=}")
|
|
shift 1
|
|
;;
|
|
--platform)
|
|
DOCKERFILE_ARGS+=("--platform")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--platform=*)
|
|
DOCKERFILE_ARGS+=("--platform" "${1#--platform=}")
|
|
shift 1
|
|
;;
|
|
--progress)
|
|
DOCKERFILE_ARGS+=("--progress")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--progress=*)
|
|
DOCKERFILE_ARGS+=("--progress" "${1#--progress=}")
|
|
shift 1
|
|
;;
|
|
--provenance)
|
|
DOCKERFILE_ARGS+=("--provenance")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--provenance=*)
|
|
DOCKERFILE_ARGS+=("--provenance" "${1#--provenance=}")
|
|
shift 1
|
|
;;
|
|
--sbom)
|
|
DOCKERFILE_ARGS+=("--sbom")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--sbom=*)
|
|
DOCKERFILE_ARGS+=("--sbom" "${1#--sbom=}")
|
|
shift 1
|
|
;;
|
|
--secret)
|
|
DOCKERFILE_ARGS+=("--secret")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--secret=*)
|
|
DOCKERFILE_ARGS+=("--secret" "${1#--secret=}")
|
|
shift 1
|
|
;;
|
|
--shm-size)
|
|
DOCKERFILE_ARGS+=("--shm-size")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--shm-size=*)
|
|
DOCKERFILE_ARGS+=("--shm-size" "${1#--shm-size=}")
|
|
shift 1
|
|
;;
|
|
--ssh)
|
|
DOCKERFILE_ARGS+=("--ssh")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--ssh=*)
|
|
DOCKERFILE_ARGS+=("--ssh" "${1#--ssh=}")
|
|
shift 1
|
|
;;
|
|
--tag)
|
|
DOCKERFILE_ARGS+=("--tag")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--tag=*)
|
|
DOCKERFILE_ARGS+=("--tag" "${1#--tag=}")
|
|
shift 1
|
|
;;
|
|
--target)
|
|
DOCKERFILE_ARGS+=("--target")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--target=*)
|
|
DOCKERFILE_ARGS+=("--target" "${1#--target=}")
|
|
shift 1
|
|
;;
|
|
--ulimit)
|
|
DOCKERFILE_ARGS+=("--ulimit")
|
|
DOCKERFILE_ARGS+=("$2")
|
|
shift 2
|
|
;;
|
|
--ulimit=*)
|
|
DOCKERFILE_ARGS+=("--ulimit" "${1#--ulimit=}")
|
|
shift 1
|
|
;;
|
|
--check | -D | --debug | --no-cache)
|
|
DOCKERFILE_ARGS+=("$1")
|
|
shift 1
|
|
;;
|
|
*)
|
|
if [[ -n "$1" ]]; then
|
|
shift
|
|
continue
|
|
fi
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
|
|
eval "$(config_export app "$APP")"
|
|
local DOCKER_CONFIG
|
|
DOCKER_CONFIG="$(fn-registry-docker-config-dir "$APP")"
|
|
[[ -n "$DOCKER_CONFIG" ]] && export DOCKER_CONFIG
|
|
"$DOCKER_BIN" image build "${DOCKER_BUILD_LABEL_ARGS[@]}" "${DOCKERFILE_ARGS[@]}" --tag $IMAGE .
|
|
|
|
plugn trigger ports-set-detected "$APP" "$(fn-builder-dockerfile-get-detect-port-map "$APP" "$IMAGE" "$SOURCECODE_WORK_DIR/Dockerfile")"
|
|
if fn-plugn-trigger-exists "post-build-dockerfile"; then
|
|
dokku_log_warn "Deprecated: please upgrade plugin to use 'post-build' plugin trigger instead of post-build-dockerfile"
|
|
plugn trigger post-build-dockerfile "$APP"
|
|
fi
|
|
plugn trigger post-build "$BUILDER_TYPE" "$APP" "$SOURCECODE_WORK_DIR"
|
|
}
|
|
|
|
trigger-builder-dockerfile-builder-build "$@"
|