fix(kestra-init): add basic auth support via KESTRA_USER/KESTRA_PASSWORD
All checks were successful
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 33s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 1m9s
Build and Push Docker Images / Build Integrator (push) Successful in 56s
Build and Push Docker Images / Build Kestra Init (push) Successful in 32s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 0s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 20:03:07 +00:00
parent 377d47eca2
commit 7072d37541
2 changed files with 11 additions and 3 deletions

View File

@@ -116,6 +116,8 @@ services:
container_name: schoolcompare_kestra_init container_name: schoolcompare_kestra_init
environment: environment:
KESTRA_URL: http://kestra:8080 KESTRA_URL: http://kestra:8080
KESTRA_USER: ${KESTRA_USER:-}
KESTRA_PASSWORD: ${KESTRA_PASSWORD:-}
depends_on: depends_on:
kestra: kestra:
condition: service_healthy condition: service_healthy

View File

@@ -4,9 +4,15 @@ set -e
KESTRA_URL="${KESTRA_URL:-http://kestra:8080}" KESTRA_URL="${KESTRA_URL:-http://kestra:8080}"
MAX_WAIT=120 MAX_WAIT=120
# Basic auth — set KESTRA_USER / KESTRA_PASSWORD if authentication is enabled
AUTH=""
if [ -n "$KESTRA_USER" ] && [ -n "$KESTRA_PASSWORD" ]; then
AUTH="-u ${KESTRA_USER}:${KESTRA_PASSWORD}"
fi
echo "Waiting for Kestra API at ${KESTRA_URL}..." echo "Waiting for Kestra API at ${KESTRA_URL}..."
elapsed=0 elapsed=0
until curl -sf "${KESTRA_URL}/api/v1/flows/search" > /dev/null 2>&1; do until curl -sf $AUTH "${KESTRA_URL}/api/v1/flows/search" > /dev/null 2>&1; do
if [ "$elapsed" -ge "$MAX_WAIT" ]; then if [ "$elapsed" -ge "$MAX_WAIT" ]; then
echo "ERROR: Kestra API not reachable after ${MAX_WAIT}s" echo "ERROR: Kestra API not reachable after ${MAX_WAIT}s"
exit 1 exit 1
@@ -22,7 +28,7 @@ for f in /flows/*.yml; do
name="$(basename "$f")" name="$(basename "$f")"
echo " -> $name" echo " -> $name"
http_code=$(curl -s -o /tmp/kestra_resp -w "%{http_code}" \ http_code=$(curl -s $AUTH -o /tmp/kestra_resp -w "%{http_code}" \
-X POST "${KESTRA_URL}/api/v1/flows" \ -X POST "${KESTRA_URL}/api/v1/flows" \
-H "Content-Type: application/x-yaml" \ -H "Content-Type: application/x-yaml" \
--data-binary "@${f}") --data-binary "@${f}")
@@ -32,7 +38,7 @@ for f in /flows/*.yml; do
elif [ "$http_code" = "409" ]; then elif [ "$http_code" = "409" ]; then
ns=$(grep '^namespace:' "$f" | awk '{print $2}') ns=$(grep '^namespace:' "$f" | awk '{print $2}')
id=$(grep '^id:' "$f" | awk '{print $2}') id=$(grep '^id:' "$f" | awk '{print $2}')
http_code2=$(curl -s -o /tmp/kestra_resp -w "%{http_code}" \ http_code2=$(curl -s $AUTH -o /tmp/kestra_resp -w "%{http_code}" \
-X PUT "${KESTRA_URL}/api/v1/flows/${ns}/${id}" \ -X PUT "${KESTRA_URL}/api/v1/flows/${ns}/${id}" \
-H "Content-Type: application/x-yaml" \ -H "Content-Type: application/x-yaml" \
--data-binary "@${f}") --data-binary "@${f}")