- Add the event results page with schedule, rankings, Battle bracket, athletes, records, bilingual labels, and navigation entry. - Add the read/write competition data service, a complete Excel example, empty public state, and validation smoke tests. - Handle Furion statusCode/data responses from the production API and retain static fallback for the public page. - Document Docker sidecar deployment beside test_eventapi, persistent storage, private admin access, Nginx routing, and OSS asset rewriting. Verification: - node server/competition-api.smoke.mjs - node scripts/competition-response-test.mjs - node scripts/battle-layout-test.mjs - npm run build -- --base=https://assets.example.test/static/test/ - npm run rewrite:oss -- https://assets.example.test/static/test/ - Production /api/competition/state returned HTTP 200 after the sidecar started. Deployment note: publish the updated YD-WEB static build before public results can consume the unwrapped API response. The event remains unpublished until an administrator saves and publishes data.
53 lines
1.5 KiB
Bash
53 lines
1.5 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
cd "$script_dir"
|
|
|
|
backend_container=${BACKEND_CONTAINER:-test_eventapi}
|
|
service_container=${SERVICE_CONTAINER:-yd-competition-api}
|
|
image_name=${IMAGE_NAME:-yd-competition-api:local}
|
|
volume_name=${DATA_VOLUME:-yd-competition-data}
|
|
|
|
if [ "$(docker inspect --format '{{.State.Running}}' "$backend_container")" != true ]; then
|
|
echo "Backend container is not running: $backend_container" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if docker container inspect "$service_container" >/dev/null 2>&1; then
|
|
echo "Service container already exists: $service_container" >&2
|
|
exit 1
|
|
fi
|
|
|
|
docker build -f Dockerfile -t "$image_name" .
|
|
docker volume create "$volume_name" >/dev/null
|
|
docker run -d \
|
|
--name "$service_container" \
|
|
--restart unless-stopped \
|
|
--network "container:$backend_container" \
|
|
--mount "type=volume,source=$volume_name,target=/app/data" \
|
|
"$image_name"
|
|
|
|
ready=false
|
|
attempt=0
|
|
while [ "$attempt" -lt 20 ]; do
|
|
if docker exec "$backend_container" sh -c \
|
|
'curl -fsS --max-time 5 http://127.0.0.1:8787/api/competition/ping' >/dev/null 2>&1; then
|
|
ready=true
|
|
break
|
|
fi
|
|
attempt=$((attempt + 1))
|
|
sleep 1
|
|
done
|
|
|
|
if [ "$ready" != true ]; then
|
|
echo "Competition API did not become ready on 127.0.0.1:8787" >&2
|
|
docker logs --tail 30 "$service_container" >&2
|
|
exit 1
|
|
fi
|
|
|
|
docker exec "$backend_container" sh -c \
|
|
'curl -fsS --max-time 5 http://127.0.0.1:8787/api/competition/ping'
|
|
echo
|
|
echo "Competition API is running beside $backend_container"
|