Skip to content

Commit f4ee662

Browse files
committed
fix: add --ignore-buildable option to pull command to skip services with build sections
1 parent b6e3c72 commit f4ee662

3 files changed

Lines changed: 33 additions & 6 deletions

File tree

source/compose.manager/scripts/compose.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ case $command in
243243

244244
pull)
245245
if [ "$debug" = true ]; then
246-
log_msg "DEBUG" "${compose_base[*]} -p $name pull"
246+
log_msg "DEBUG" "${compose_base[*]} -p $name pull --ignore-buildable"
247247
fi
248248

249-
"${compose_base[@]}" -p "$name" pull
249+
"${compose_base[@]}" -p "$name" pull --ignore-buildable
250250
exit_code=$?
251251

252252
if [ $exit_code -eq 0 ]; then
@@ -264,7 +264,7 @@ case $command in
264264
update)
265265
if [ "$debug" = true ]; then
266266
log_msg "DEBUG" "${compose_base[*]} -p $name images -q"
267-
log_msg "DEBUG" "${compose_base[*]} -p $name pull"
267+
log_msg "DEBUG" "${compose_base[*]} -p $name pull --ignore-buildable"
268268
log_msg "DEBUG" "${compose_base[*]} -p $name up -d --build"
269269
fi
270270

@@ -291,9 +291,9 @@ case $command in
291291
images=( "${images[@]##sha256:}" )
292292
fi
293293

294-
# Pull latest images
294+
# Pull latest images (--ignore-buildable: skip services with build sections, they are rebuilt by up --build)
295295
echo "Pulling latest images..."
296-
"${compose_base[@]}" -p "$name" pull
296+
"${compose_base[@]}" -p "$name" pull --ignore-buildable
297297
pull_exit=$?
298298

299299
if [ $pull_exit -ne 0 ]; then

source/compose.manager/scripts/compose_autoupdate.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ get_image_digests() {
5959
OLD_DIGESTS=$(get_image_digests || true)
6060

6161
# Run pull and capture output (timeout prevents indefinite hangs on unresponsive registries)
62-
timeout "$COMMAND_TIMEOUT" docker compose -f "$COMPOSE_FILE" -p "$PROJECT_NAME" pull > "$OUT" 2>&1 || RC=$?
62+
# --ignore-buildable: skip services with build sections (they should be rebuilt, not pulled)
63+
timeout "$COMMAND_TIMEOUT" docker compose -f "$COMPOSE_FILE" -p "$PROJECT_NAME" pull --ignore-buildable > "$OUT" 2>&1 || RC=$?
6364

6465
if [ "$RC" -ne 0 ]; then
6566
ERRMSG="Auto-update pull failed for '$PROJECT_NAME'. Recent output: $(summarize_output)"

tests/unit/compose.bats

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,32 @@ test_setup() {
8484
assert_failure
8585
}
8686

87+
# ============================================================
88+
# --ignore-buildable Flag Tests
89+
# ============================================================
90+
91+
@test "compose.sh pull action uses --ignore-buildable" {
92+
# Ensure the pull action always passes --ignore-buildable to skip build-only services
93+
run grep -E '^\s*"\$\{compose_base\[@\]\}" -p "\$name" pull --ignore-buildable' "$COMPOSE_SCRIPT"
94+
assert_success
95+
}
96+
97+
@test "compose.sh update action pull step uses --ignore-buildable" {
98+
# The update action pulls before 'up -d --build'; buildable services are handled by --build
99+
run grep -E 'pull --ignore-buildable' "$COMPOSE_SCRIPT"
100+
assert_success
101+
# Should appear at least twice (pull action + update action)
102+
local count
103+
count=$(grep -cE 'pull --ignore-buildable' "$COMPOSE_SCRIPT")
104+
[ "$count" -ge 2 ]
105+
}
106+
107+
@test "compose_autoupdate.sh uses --ignore-buildable" {
108+
local autoupdate_script="$BATS_TEST_DIRNAME/../../source/compose.manager/scripts/compose_autoupdate.sh"
109+
run grep -E 'pull --ignore-buildable' "$autoupdate_script"
110+
assert_success
111+
}
112+
87113
# ============================================================
88114
# Stack Directory Tests
89115
# ============================================================

0 commit comments

Comments
 (0)