Merge pull request #8266 from dokku/6847-allow-force-pull-image-on-git-from-image

Add a method to force build when re-using an image with git:from-image
This commit is contained in:
Jose Diaz-Gonzalez
2026-01-08 12:11:54 -05:00
committed by GitHub
4 changed files with 48 additions and 4 deletions

View File

@@ -26,9 +26,16 @@ trigger-git-git-from-image() {
echo "FROM $DOCKER_IMAGE" >>"$TMP_WORK_DIR/Dockerfile"
echo "LABEL com.dokku.docker-image-labeler/alternate-tags=[\\\"$DOCKER_IMAGE\\\"]" >>"$TMP_WORK_DIR/Dockerfile"
if [[ "$(docker images -q "$DOCKER_IMAGE" 2>/dev/null)" == "" ]]; then
if [[ "$("$DOCKER_BIN" image ls -q "$DOCKER_IMAGE" 2>/dev/null)" == "" ]]; then
dokku_log_info1 "Pulling image"
"$DOCKER_BIN" image pull "$DOCKER_IMAGE"
if ! "$DOCKER_BIN" image pull "$DOCKER_IMAGE"; then
dokku_log_fail "Failed to pull image: $DOCKER_IMAGE"
fi
elif [[ "$DOKKU_APPS_FORCE_DELETE" == "1" ]]; then
dokku_log_info1 "Force pulling image"
if ! "$DOCKER_BIN" image pull "$DOCKER_IMAGE"; then
dokku_log_fail "Failed to pull image: $DOCKER_IMAGE"
fi
else
dokku_log_info1 "Image exists on host, skipping pull"
fi

View File

@@ -141,7 +141,7 @@ cmd-git-from-image() {
local cmd="git:from-image"
[[ "$1" == "$cmd" ]] && shift 1
declare APP DOCKER_IMAGE USER_NAME USER_EMAIL
local BUILD_DIR
local BUILD_DIR FORCE=false
ARGS=()
skip=false
@@ -151,6 +151,11 @@ cmd-git-from-image() {
continue
fi
if [[ "$arg" == "--force" ]]; then
FORCE=true
continue
fi
if [[ "$skip" == "true" ]]; then
BUILD_DIR="$arg"
skip=false
@@ -168,6 +173,10 @@ cmd-git-from-image() {
verify_app_name "$APP"
[[ -z "$DOCKER_IMAGE" ]] && dokku_log_fail "Please specify a docker image"
if [[ "$FORCE" == "true" ]]; then
export DOKKU_APPS_FORCE_DELETE=1
fi
if ! plugn trigger git-from-image "$APP" "$DOCKER_IMAGE" "$BUILD_DIR" "$USER_NAME" "$USER_EMAIL"; then
return 1
fi