@@ -105,12 +105,49 @@ call_web_app() {
105105
106106 # Get the Docker container name (with retries, as the container may take time to start after deployment)
107107 echo " Finding container name with prefix [ls-$web_app_name ]..."
108- MAX_RETRIES=30
108+ MAX_RETRIES=18
109109 RETRY_INTERVAL=10
110110 container_name=" "
111111 for (( attempt= 1 ; attempt<= MAX_RETRIES; attempt++ )) ; do
112112 container_name=$( get_docker_container_name_by_prefix " ls-$web_app_name " ) && break
113113 container_name=" "
114+
115+ # Print full diagnostics on first, every 6th, and last attempt
116+ if [ " $attempt " -eq 1 ] || [ " $(( attempt % 6 )) " -eq 0 ] || [ " $attempt " -eq " $MAX_RETRIES " ]; then
117+ echo " === DEBUG (attempt $attempt /$MAX_RETRIES ): Container diagnostics ==="
118+
119+ echo " --- All running containers ---"
120+ docker ps --format " table {{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1
121+
122+ echo " --- All containers (including stopped/exited) ---"
123+ docker ps -a --format " table {{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1
124+
125+ echo " --- Docker images ---"
126+ docker images --format " table {{.Repository}}\t{{.Tag}}\t{{.ID}}" 2>&1
127+
128+ # Check LocalStack logs for web app container creation errors
129+ LS_CONTAINER=$( docker ps --format " {{.Names}}" | grep -i " localstack" | head -1)
130+ if [ -n " $LS_CONTAINER " ]; then
131+ echo " --- LocalStack logs (last 50 lines, filtered for webapp/container/error) ---"
132+ docker logs " $LS_CONTAINER " --tail 200 2>&1 | grep -iE " (ls-${web_app_name} |webapp.*container|container.*webapp|pip.*install|requirements|cryptography|certificates|import.*error|module.*not.*found|build.*fail|error.*build|startup|gunicorn|flask)" | tail -50 || echo " (no matching log lines)"
133+
134+ echo " --- LocalStack logs (last 30 lines, unfiltered) ---"
135+ docker logs " $LS_CONTAINER " --tail 30 2>&1
136+ fi
137+
138+ # Show logs from any exited containers
139+ EXITED=$( docker ps -a --filter " status=exited" --format " {{.Names}}" 2> /dev/null)
140+ if [ -n " $EXITED " ]; then
141+ echo " --- Exited container logs ---"
142+ echo " $EXITED " | while read -r c; do
143+ echo " [$c ] logs (last 20 lines):"
144+ docker logs " $c " --tail 20 2>&1 | sed ' s/^/ /'
145+ done
146+ fi
147+
148+ echo " === END DEBUG ==="
149+ fi
150+
114151 if [ " $attempt " -lt " $MAX_RETRIES " ]; then
115152 echo " Attempt $attempt /$MAX_RETRIES : Container not found yet. Waiting ${RETRY_INTERVAL} s..."
116153 sleep " $RETRY_INTERVAL "
0 commit comments