# shellcheck shell=bash [[ -n "${BOLT_DOCKER_LOADED:-}" ]] && return readonly BOLT_DOCKER_LOADED=1 source "$(dirname "${BASH_SOURCE[0]}")/log.sh" docker_compose_up() { local compose_file="$1" log_info "Starting services from '$compose_file'..." docker compose --file "$compose_file" up --detach } docker_compose_down() { local compose_file="$1" log_info "Stopping services from '$compose_file'..." docker compose --file "$compose_file" down } docker_wait_for_healthy_container() { local container_name="$1" local timeout="${2:-60}" local elapsed=0 log_info "Waiting for container '$container_name' to be healthy..." while [[ $elapsed -lt $timeout ]]; do local status status=$(docker inspect -f '{{.State.Health.Status}}' "$container_name" 2>/dev/null || echo "not_found") case "$status" in "healthy") log_success "Container '$container_name' is healthy!" return 0 ;; "not_found") log_error "Error: Container '$container_name' not found" return 1 ;; "unhealthy") log_error "Error: Container '$container_name' is unhealthy" return 1 ;; *) log_progress sleep 1 ((elapsed++)) ;; esac done log_progress_end log_error "Timeout: Container '$container_name' did not become healthy within ${timeout} seconds" return 1 }