Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(ci): add --only flag to wait-for-docker helpers (#59693)

Raúl Negrón-Otero98ff8bd15e98
diff --git a/bin/ci-wait-for-docker b/bin/ci-wait-for-docker
index 20d76e7b0c53..289298d8ee5b 100755
--- a/bin/ci-wait-for-docker
+++ b/bin/ci-wait-for-docker
@@ -26,9 +26,12 @@ usage() {
cat <<'EOF'
Usage:
bin/ci-wait-for-docker launch [--down|--down-all-profiles] [--background] [services...]
- bin/ci-wait-for-docker wait [services...]
+ bin/ci-wait-for-docker wait [--only] [services...]
`wait` is the default command when omitted.
+With no args, `wait` blocks on the core stack (db redis7 kafka clickhouse).
+Extra services are appended to the core list. Pass `--only` to wait ONLY for
+the listed services (skipping core) — for jobs that launched a subset.
EOF
}
@@ -259,8 +262,31 @@ run_launch() {
}
run_wait() {
- local core_services=(db redis7 kafka clickhouse)
- local wait_services=("${core_services[@]}" "$@")
+ # Default: wait for core (db redis7 kafka clickhouse) plus any extras passed
+ # as args — matches `bin/wait-for-docker`'s semantics so the two helpers stay
+ # consistent. Pass `--only` as the first arg to wait ONLY for the listed
+ # services (skipping core) — for CI jobs that intentionally launch a subset
+ # of the stack and shouldn't block on services they never started.
+ local default_services=(db redis7 kafka clickhouse)
+ local only_listed=0
+ local forward_args=()
+ if [ "${1:-}" = "--only" ]; then
+ only_listed=1
+ shift
+ if [ "$#" -eq 0 ]; then
+ echo "ci-wait-for-docker wait: --only requires at least one service argument" >&2
+ return 2
+ fi
+ forward_args=(--only "$@")
+ else
+ forward_args=("$@")
+ fi
+ local wait_services
+ if [ "$only_listed" -eq 1 ]; then
+ wait_services=("$@")
+ else
+ wait_services=("${default_services[@]}" "$@")
+ fi
local initial_timeout="${WAIT_FOR_DOCKER_TIMEOUT:-300}"
local current_timeout="$initial_timeout"
local attempt=0
@@ -279,7 +305,7 @@ run_wait() {
echo "Proceeding with readiness checks even though the background docker compose launch is still running."
fi
- if WAIT_FOR_DOCKER_TIMEOUT="$current_timeout" "${SCRIPT_DIR}/wait-for-docker" "$@"; then
+ if WAIT_FOR_DOCKER_TIMEOUT="$current_timeout" "${SCRIPT_DIR}/wait-for-docker" "${forward_args[@]}"; then
return 0
fi
diff --git a/bin/wait-for-docker b/bin/wait-for-docker
index 092514dd8214..87a375272aa9 100755
--- a/bin/wait-for-docker
+++ b/bin/wait-for-docker
@@ -5,8 +5,10 @@ set -euo pipefail
# Read-only: does not start, stop, or recreate any containers.
# Used by phrocs processes to block until infrastructure is ready.
#
-# Always checks core services (db, redis7, kafka, clickhouse).
-# Pass extra service names as arguments, e.g.: bin/wait-for-docker temporal
+# Usage:
+# bin/wait-for-docker # wait for core (db redis7 kafka clickhouse)
+# bin/wait-for-docker temporal # wait for core + temporal
+# bin/wait-for-docker --only db redis7 # wait only for db and redis7 (skip core)
# In a sandbox container, infra is managed by docker compose externally
# and is guaranteed healthy via depends_on health checks.
@@ -20,8 +22,22 @@ REPO_ROOT="$(dirname "$SCRIPT_DIR")"
DEFAULT_COMPOSE_FILE="${REPO_ROOT}/docker-compose.dev.yml"
TIMEOUT="${WAIT_FOR_DOCKER_TIMEOUT:-300}"
-SERVICES=(db redis7 kafka clickhouse)
-SERVICES+=("$@")
+only_listed=0
+if [ "${1:-}" = "--only" ]; then
+ only_listed=1
+ shift
+fi
+
+if [ "$only_listed" -eq 1 ]; then
+ if [ "$#" -eq 0 ]; then
+ echo "wait-for-docker: --only requires at least one service argument" >&2
+ exit 2
+ fi
+ SERVICES=("$@")
+else
+ SERVICES=(db redis7 kafka clickhouse)
+ SERVICES+=("$@")
+fi
unique_services=()
for svc in "${SERVICES[@]}"; do