* fix(docker): make wait-for-api.sh POSIX and enforce LF line endings (#586) * fix: restore inline comment on final exit 0 Addresses review feedback: the comment on the final `exit 0` explains a non-obvious design decision (frontend still starts when the API never became ready, so users get a usable UI with connection errors rather than a dead container). --------- Co-authored-by: Luis Novo <lfnovo@gmail.com>
This commit is contained in:
parent
4efe613f69
commit
4d4330fb3f
2 changed files with 8 additions and 3 deletions
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Ensure shell scripts always use LF so they run in Linux containers (e.g. Docker)
|
||||
*.sh text eol=lf
|
||||
|
|
@ -1,18 +1,21 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# Wait for the API to be healthy before starting the frontend
|
||||
# This prevents the "Unable to Connect to API Server" error during startup
|
||||
# POSIX-compliant so it runs with /bin/sh (dash) in slim images
|
||||
|
||||
API_URL="${INTERNAL_API_URL:-http://localhost:5055}"
|
||||
MAX_RETRIES=60 # 60 retries * 5 seconds = 5 minutes max wait
|
||||
MAX_RETRIES=60
|
||||
RETRY_INTERVAL=5
|
||||
i=0
|
||||
|
||||
echo "Waiting for API to be ready at ${API_URL}/health..."
|
||||
|
||||
for i in $(seq 1 $MAX_RETRIES); do
|
||||
while [ $i -lt $MAX_RETRIES ]; do
|
||||
if curl -s -f "${API_URL}/health" > /dev/null 2>&1; then
|
||||
echo "API is ready! Starting frontend..."
|
||||
exit 0
|
||||
fi
|
||||
i=$((i + 1))
|
||||
echo "Attempt $i/$MAX_RETRIES: API not ready yet, waiting ${RETRY_INTERVAL}s..."
|
||||
sleep $RETRY_INTERVAL
|
||||
done
|
||||
|
|
|
|||
Loading…
Reference in a new issue