trails/docker/brouter/entrypoint.sh
Ullrich Schäfer 46743a91db
Auto-download BRouter segments on first container start
Fresh `pnpm dev:services` checkouts came up with an empty
brouter_segments volume, so every routing request returned
"datafile not found" and the e2e suite's BRouter tests failed.

Add an entrypoint that runs download-segments.sh when /data/segments
has no rd5 files, then exec's the existing server command. Subsequent
starts find the populated volume and skip straight to the server.
Keep wget in the final image (previously stripped) so the entrypoint
can fetch segments at runtime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 00:43:43 +02:00

16 lines
578 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
SEGMENTS_DIR="/data/segments"
# Auto-populate segments on first start. The named volume is empty after
# `docker compose up`, which leaves BRouter returning 400 for every routing
# request. Downloading here means a fresh checkout works end-to-end without
# extra setup steps. On subsequent starts the rd5 files are already present
# and we skip straight to the server.
if ! ls "$SEGMENTS_DIR"/*.rd5 >/dev/null 2>&1; then
echo "No segments found in $SEGMENTS_DIR — downloading…"
/brouter/download-segments.sh "$SEGMENTS_DIR"
fi
exec "$@"