Merge pull request #9225 from dokku/9224-add-a-way-to-rebuild-an-app-without-build-cache-on-demand

Add --no-cache flag to ps:rebuild
This commit is contained in:
Jose Diaz-Gonzalez authored and GitHub committed 2026-10-29 21:05:57 -04:00
commit 8f11b7900a
27 files changed
+318 -9

No files matched your search

+4
View File
@@ -279,6 +279,10 @@ trigger-builder-dockerfile-builder-build() {
esac
done
if [[ "$DOKKU_BUILD_NO_CACHE" == "true" ]] && ! fn-in-array "--no-cache" "${DOCKERFILE_ARGS[@]}"; then
DOCKERFILE_ARGS+=("--no-cache")
fi
eval "$(config_export app "$APP")"
local DOCKER_CONFIG
DOCKER_CONFIG="$(fn-registry-docker-config-dir "$APP")"
+4
View File
@@ -77,6 +77,10 @@ trigger-builder-herokuish-builder-build() {
done < <(fn-docker-args-split "$DOCKER_ARGS")
local DOKKU_CONTAINER_EXIT_CODE=0
if [[ "$DOKKU_BUILD_NO_CACHE" == "true" ]]; then
dokku_log_info1 "Clearing build cache"
plugn trigger repo-purge-cache "$APP"
fi
fn-builder-herokuish-ensure-cache "$APP"
if ! CID=$("$DOCKER_BIN" container create "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS -v "cache-$APP:/cache" --env=CACHE_PATH=/cache "${ARG_ARRAY[@]}" "$IMAGE" /build); then
plugn trigger scheduler-register-retired "$APP" "$CID"
+4
View File
@@ -244,6 +244,10 @@ trigger-builder-nixpacks-builder-build() {
esac
done
if [[ "$DOKKU_BUILD_NO_CACHE" == "true" ]] && ! fn-in-array "--no-cache" "${NIXPACKS_ARGS[@]}"; then
NIXPACKS_ARGS+=("--no-cache")
fi
eval "$(config_export app "$APP" --merged)"
local DOCKER_CONFIG
+4
View File
@@ -282,6 +282,10 @@ trigger-builder-pack-builder-build() {
esac
done
if [[ "$DOKKU_BUILD_NO_CACHE" == "true" ]] && ! fn-in-array "--clear-cache" "${PACK_ARGS[@]}"; then
PACK_ARGS+=("--clear-cache")
fi
if [ -n "$BUILDPACK_URL" ]; then
PACK_ARGS+=("--builder")
PACK_ARGS+=("$BUILDPACK_URL")
+5 -1
View File
@@ -112,7 +112,7 @@ trigger-builder-railpack-builder-build() {
RAILPACK_ARGS+=("--start-cmd" "${1#--start-cmd=}")
shift 1
;;
---show-plan | --error-missing-start)
---show-plan | --error-missing-start | --no-cache)
RAILPACK_ARGS+=("$1")
shift 1
;;
@@ -126,6 +126,10 @@ trigger-builder-railpack-builder-build() {
esac
done
if [[ "$DOKKU_BUILD_NO_CACHE" == "true" ]] && ! fn-in-array "--no-cache" "${RAILPACK_ARGS[@]}"; then
RAILPACK_ARGS+=("--no-cache")
fi
eval "$(config_export app "$APP" --merged)"
local DOCKER_CONFIG
+24
View File
@@ -942,6 +942,30 @@ merge_dedupe_list() {
echo "$merged_list"
}
fn-build-capture-app-name() {
declare desc="outputs the app name from the arguments of a build-capturing command, skipping any flags"
shift 1
while [[ $# -gt 0 ]]; do
case "$1" in
--all)
return 0
;;
--parallel)
shift 1
[[ $# -gt 0 ]] && shift 1
;;
-*)
shift 1
;;
*)
echo "$1"
return 0
;;
esac
done
}
dokku_setup_build_capture() {
declare desc="generate a build-id, write a record, and redirect output to log + journald"
declare APP="$1" SOURCE="${2:-unknown}"
+1 -1
View File
@@ -19,7 +19,7 @@ Additional commands:`
helpContent = `
ps:inspect <app>, Displays a sanitized version of docker inspect for an app
ps:rebuild [--parallel count] [--all|<app>], Rebuilds an app from source
ps:rebuild [--parallel count] [--no-cache] [--all|<app>], Rebuilds an app from source
ps:report [<app>] [<flag>], Displays a process report for one or more apps
ps:restart [--parallel count] [--all|<app>] [<process-name>], Restart an app
ps:restore [<app>], Start previously running apps e.g. after reboot
+2 -1
View File
@@ -27,9 +27,10 @@ func main() {
args := flag.NewFlagSet("ps:rebuild", flag.ExitOnError)
allApps := args.Bool("all", false, "--all: rebuild all apps")
parallelCount := args.Int("parallel", ps.RunInSerial, "--parallel: number of apps to rebuild in parallel, -1 to match cpu count")
noCache := args.Bool("no-cache", false, "--no-cache: rebuild without using the build cache")
args.Parse(os.Args[2:])
appName := args.Arg(0)
err = ps.CommandRebuild(appName, *allApps, *parallelCount)
err = ps.CommandRebuild(appName, *allApps, *parallelCount, *noCache)
case "report":
args := flag.NewFlagSet("ps:report", flag.ExitOnError)
format := args.String("format", "stdout", "format: [ stdout | json ]")
+6 -1
View File
@@ -3,6 +3,7 @@ package ps
import (
"errors"
"fmt"
"os"
"path/filepath"
"strings"
@@ -26,7 +27,11 @@ func CommandInspect(appName string) error {
}
// CommandRebuild rebuilds an app from source
func CommandRebuild(appName string, allApps bool, parallelCount int) error {
func CommandRebuild(appName string, allApps bool, parallelCount int, noCache bool) error {
if noCache {
os.Setenv("DOKKU_BUILD_NO_CACHE", "true")
}
if allApps {
return common.RunCommandAgainstAllApps(Rebuild, "rebuild", parallelCount)
}
+1 -1
View File
@@ -1,5 +1,5 @@
SUBCOMMANDS = subcommands/gc subcommands/purge-cache
TRIGGERS = triggers/post-stack-set triggers/post-delete
TRIGGERS = triggers/post-stack-set triggers/post-delete triggers/repo-purge-cache
BUILD = commands subcommands triggers
PLUGIN_NAME = repo
+3
View File
@@ -24,6 +24,9 @@ func main() {
case "post-delete":
appName := flag.Arg(0)
err = repo.PurgeCache(appName)
case "repo-purge-cache":
appName := flag.Arg(0)
err = repo.PurgeCache(appName)
default:
err = fmt.Errorf("Invalid plugin trigger call: %s", trigger)
}