#!/bin/bash set -euo pipefail # 03-setup-container.sh — Build container image and verify with test run SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)" LOG_FILE="$PROJECT_ROOT/logs/setup.log" mkdir -p "$PROJECT_ROOT/logs" log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] [setup-container] $*" >> "$LOG_FILE"; } # Parse args RUNTIME="" while [[ $# -gt 0 ]]; do case $1 in --runtime) RUNTIME="$2"; shift 2 ;; *) shift ;; esac done if [ -z "$RUNTIME" ]; then log "ERROR: --runtime flag is required (apple-container|docker)" cat </dev/null 2>&1; then log "Apple Container runtime not found" cat </dev/null 2>&1 || ! docker info >/dev/null 2>&1; then log "Docker runtime not available or not running" cat <> "$LOG_FILE" 2>&1; then BUILD_OK="true" log "Container build succeeded" else log "Container build failed" cat <>"$LOG_FILE") || true if echo "$TEST_OUTPUT" | grep -q "Container OK"; then TEST_OK="true" log "Container test passed" else log "Container test failed: $TEST_OUTPUT" fi STATUS="success" if [ "$BUILD_OK" = "false" ] || [ "$TEST_OK" = "false" ]; then STATUS="failed" fi cat <