#!/bin/sh set -eu cd "$(dirname "$0")/.." compose="docker compose --profile external" marker="smoke-$(date +%s)-$$" headers="" # Avoid colliding with a developer's existing service. Production/developer Compose still # defaults to 8080; a published port of 0 asks Docker for a free ephemeral smoke port. export THOTH_HTTP_PORT=${THOTH_HTTP_PORT:-0} cleanup() { if [ -n "$headers" ]; then rm -f "$headers"; fi # Deliberately omit --volumes: an ordinary smoke run must preserve user data. $compose down --remove-orphans >/dev/null 2>&1 || true } trap cleanup EXIT HUP INT TERM $compose config --quiet $compose up --build --wait core frontend published=$($compose port frontend 8080) http_port=${published##*:} curl --fail --silent --show-error "http://127.0.0.1:$http_port/health" >/dev/null # The nginx proxy must preserve streaming semantics for the backend SSE endpoint. headers=$(mktemp) curl --fail --silent --show-error --max-time 2 --dump-header "$headers" \ "http://127.0.0.1:$http_port/api/sessions/docker-smoke/events" \ >/dev/null 2>&1 || status=$? status=${status:-0} if [ "$status" -ne 0 ] && [ "$status" -ne 28 ]; then echo "SSE probe failed with curl status $status" >&2 exit "$status" fi grep -qi '^content-type: text/event-stream' "$headers" grep -qi '^cache-control: no-cache' "$headers" rm -f "$headers" headers="" # Write through the named volume, restart the application, and prove persistence. $compose exec -T core sh -c 'printf "%s\n" "$1" > /data/.compose-smoke-marker' sh "$marker" $compose restart core $compose up --wait core frontend persisted=$($compose exec -T core sh -c 'cat /data/.compose-smoke-marker') [ "$persisted" = "$marker" ] $compose exec -T core rm -f /data/.compose-smoke-marker curl --fail --silent --show-error "http://127.0.0.1:$http_port/health" >/dev/null echo "Compose health, SSE proxy, and restart persistence checks passed."