feat: migrate builds plugin to go and track per-build records
Adds typed JSON build records under data/builds/<app>/<build-id>.{json,log} keyed on a stable base36 ULID-style DOKKU_BUILD_ID generated for every deploy. The new commands surface that history (builds:list, builds:info, builds:prune) and an operator-configurable retention via builds:set retention. The existing builds:cancel and builds:output now key on the build-id (with safe handling for already-finalized and abandoned records), and the per-build log file replaces journalctl as the durable source of truth for builds:output.
This commit is contained in:
@@ -142,7 +142,7 @@ git_receive_app() {
|
||||
local exit_code=0
|
||||
acquire_app_deploy_lock "$APP" "exclusive"
|
||||
git_build "$APP" "$REV" || exit_code="$?"
|
||||
release_app_deploy_lock "$APP"
|
||||
release_app_deploy_lock "$APP" "$exit_code"
|
||||
return "$exit_code"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -52,10 +52,7 @@ cmd-git-from-archive() {
|
||||
dokku_log_fail "Invalid archive type specified, valid archive types include: tar, tar.gz, zip"
|
||||
fi
|
||||
|
||||
if [[ "$DOKKU_REDIRECT_OUTPUT" != "true" ]]; then
|
||||
export DOKKU_REDIRECT_OUTPUT=true
|
||||
exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}"))
|
||||
fi
|
||||
dokku_setup_build_capture "$APP" "git:from-archive"
|
||||
plugn trigger git-from-archive "$APP" "$ARCHIVE_URL" "$ARCHIVE_TYPE" "$USER_NAME" "$USER_EMAIL"
|
||||
plugn trigger deploy-source-set "$APP" "$ARCHIVE_TYPE" "$ARCHIVE_URL"
|
||||
}
|
||||
@@ -166,10 +163,7 @@ cmd-git-load-image() {
|
||||
[[ -z "$DOCKER_IMAGE" ]] && dokku_log_fail "Please specify a docker image"
|
||||
[[ ! -t 0 ]] || dokku_log_fail "Expecting tar archive containing docker image on STDIN"
|
||||
|
||||
if [[ "$DOKKU_REDIRECT_OUTPUT" != "true" ]]; then
|
||||
export DOKKU_REDIRECT_OUTPUT=true
|
||||
exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}"))
|
||||
fi
|
||||
dokku_setup_build_capture "$APP" "git:load-image"
|
||||
cat | docker load
|
||||
|
||||
if ! verify_image "$DOCKER_IMAGE"; then
|
||||
@@ -223,10 +217,7 @@ cmd-git-from-image() {
|
||||
export DOKKU_APPS_FORCE_DELETE=1
|
||||
fi
|
||||
|
||||
if [[ "$DOKKU_REDIRECT_OUTPUT" != "true" ]]; then
|
||||
export DOKKU_REDIRECT_OUTPUT=true
|
||||
exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}"))
|
||||
fi
|
||||
dokku_setup_build_capture "$APP" "git:from-image"
|
||||
|
||||
if ! plugn trigger git-from-image "$APP" "$DOCKER_IMAGE" "$BUILD_DIR" "$USER_NAME" "$USER_EMAIL"; then
|
||||
return 1
|
||||
@@ -276,10 +267,7 @@ cmd-git-sync() {
|
||||
DOKKU_DEPLOY_BRANCH="$(fn-git-deploy-branch "$APP")"
|
||||
CURRENT_REF="$(fn-git-cmd "$APP_ROOT" rev-parse "$DOKKU_DEPLOY_BRANCH" 2>/dev/null || true)"
|
||||
|
||||
if [[ "$DOKKU_REDIRECT_OUTPUT" != "true" ]]; then
|
||||
export DOKKU_REDIRECT_OUTPUT=true
|
||||
exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}"))
|
||||
fi
|
||||
dokku_setup_build_capture "$APP" "git:sync"
|
||||
|
||||
if ! fn-git-cmd "$APP_ROOT" rev-parse "$DOKKU_DEPLOY_BRANCH" &>/dev/null; then
|
||||
dokku_log_info1_quiet "Cloning $APP from $GIT_REMOTE#$GIT_REF"
|
||||
|
||||
@@ -7,10 +7,7 @@ trigger-git-receive-app() {
|
||||
declare desc="builds the app from the local git repository"
|
||||
declare trigger="receive-app"
|
||||
|
||||
if [[ "$DOKKU_REDIRECT_OUTPUT" != "true" ]]; then
|
||||
export DOKKU_REDIRECT_OUTPUT=true
|
||||
exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}"))
|
||||
fi
|
||||
dokku_setup_build_capture "$1" "git-hook"
|
||||
|
||||
git_receive_app "$@"
|
||||
return $?
|
||||
|
||||
Reference in New Issue
Block a user