Rather than waiting for the next deploy, take advantage of the retire system to retire these containers immediately. Note that since the retire process happens out of band, the containers may stick around for up to 5 minutes, after which point they will be removed. Customization of the wait time to retire - currently 60 seconds - is up for future debate. The containers ultimately haven't been useful for debugging, so keeping them around for longer won't help in most cases, and folks can disable the dokku-retire service (or cron) if that is desired.
46 lines
2.2 KiB
Bash
Executable File
46 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eo pipefail
|
|
[[ $DOKKU_TRACE ]] && set -x
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
|
|
|
trigger-builder-herokuish-pre-build-buildpack() {
|
|
declare desc="builder-herokuish pre-build-buildpack plugin trigger"
|
|
declare trigger="pre-build-buildpack"
|
|
declare APP="$1"
|
|
local IMAGE CID
|
|
|
|
local DOCKER_COMMIT_LABEL_ARGS=("--change" "LABEL org.label-schema.schema-version=1.0" "--change" "LABEL org.label-schema.vendor=dokku" "--change" "LABEL com.dokku.app-name=$APP")
|
|
local DOCKER_RUN_LABEL_ARGS="--label=com.dokku.app-name=$APP"
|
|
|
|
verify_app_name "$APP"
|
|
IMAGE=$(get_app_image_name "$APP")
|
|
|
|
[[ -z $(config_get --global CURL_CONNECT_TIMEOUT) ]] && config_set --global CURL_CONNECT_TIMEOUT=90
|
|
[[ -z $(config_get --global CURL_TIMEOUT) ]] && config_set --global CURL_TIMEOUT=600
|
|
|
|
dokku_log_info1 "Adding BUILD_ENV to build environment..."
|
|
# create build env files for use in buildpacks like this:
|
|
# https://github.com/niteoweb/heroku-buildpack-buildout/blob/5879fa3418f7d8e079f1aa5816ba1adde73f4948/bin/compile#L34
|
|
CID=$(config_bundle --merged "$APP" | "$DOCKER_BIN" container run "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS -i -a stdin "$IMAGE" /bin/bash -c "mkdir -p /tmp/env; cat | tar -x -C /tmp/env")
|
|
if test "$("$DOCKER_BIN" container wait "$CID")" -ne 0; then
|
|
dokku_log_warn "Failure injecting BUILD_ENV into build environment"
|
|
return 1
|
|
fi
|
|
|
|
"$DOCKER_BIN" container commit "${DOCKER_COMMIT_LABEL_ARGS[@]}" "$CID" "$IMAGE" >/dev/null
|
|
plugn trigger scheduler-register-retired "$APP" "$CID"
|
|
|
|
# create build env for 'old style' buildpacks and dokku plugins
|
|
CID=$(config_export app "$APP" --format envfile --merged | "$DOCKER_BIN" container run "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS -i -a stdin "$IMAGE" /bin/bash -c "cat >> /app/.env")
|
|
if test "$("$DOCKER_BIN" container wait "$CID")" -ne 0; then
|
|
dokku_log_warn "Failure injecting old-style BUILD_ENV"
|
|
return 1
|
|
fi
|
|
|
|
"$DOCKER_BIN" container commit "${DOCKER_COMMIT_LABEL_ARGS[@]}" "$CID" "$IMAGE" >/dev/null
|
|
plugn trigger scheduler-register-retired "$APP" "$CID"
|
|
}
|
|
|
|
trigger-builder-herokuish-pre-build-buildpack "$@"
|