Lands sections 3-5 of the relocate-brouter-to-dedicated-host change:
everything needed to run BRouter on the dedicated Hetzner Robot host
and have the Planner talk to it with the shared-secret header. Does
NOT flip the cutover — the flagship BRouter stays warm during soak.
## BRouter host compose (section 3)
New `infrastructure/brouter-host/` — a standalone compose project that
runs as the `trails` user on `ullrich.is`:
- `docker-compose.yml` — brouter + caddy sidecar. BRouter has no host
port; caddy binds only to `10.0.1.10:17777` (vSwitch IP). Every
service explicitly overrides the host's default Loki logging driver
to `json-file` so logs don't leak to the operator's personal Loki.
- `Caddyfile` — single-purpose reverse proxy that requires
`X-BRouter-Auth: ${BROUTER_AUTH_TOKEN}` on every request. `auto_https
off` (vSwitch-only); default access log format omits request
headers, so the token is never written to disk.
- `download-segments.sh` — crawls brouter.de, pulls planet-wide RD5
tiles via `wget -N` (incremental). Idempotent, safe to cron.
- `README.md` — one-shot provisioning + token rotation + rollback
notes.
`docker/brouter/Dockerfile` is patched to honor `JAVA_OPTS` (was
hardcoded `-Xmx1024M` in CMD). Default keeps the flagship's current
heap; compose on the dedicated host overrides to `-Xmx8g` for planet
scale on a 32 GB box.
## Planner shared-secret header (section 4)
`apps/planner/app/lib/brouter.ts`:
- Module-level guard: throws at startup in production if
`BROUTER_AUTH_TOKEN` is unset.
- `authHeaders()` helper (reads env at call time, so tests can
`vi.stubEnv` without module reset).
- Header attached on both `computeRoute` (per-segment) and
`computeSegmentGpx`.
3 new unit tests cover header attachment + the no-token path.
`infrastructure/docker-compose.yml` passes `BROUTER_AUTH_TOKEN` to
the Planner service, and makes `BROUTER_URL` overridable via SOPS so
the cutover is a one-variable flip.
## cd-brouter workflow (section 5)
Rewritten to deploy to the dedicated host:
- SSH as `trails@${BROUTER_DEPLOY_HOST}` on port
`${BROUTER_DEPLOY_SSH_PORT}` (2232) using
`${BROUTER_DEPLOY_SSH_KEY}`.
- Decrypts SOPS, extracts ONLY `BROUTER_AUTH_TOKEN` into a `.env`
file, scp'd alongside the compose project.
- `paths:` trigger now includes `infrastructure/brouter-host/**`.
- Segment download is NOT run here — first-time seed is a manual
operator step (multi-hour). Routine re-runs are cron-able on the
dedicated host.
- Grafana annotation step preserved (reaches flagship Grafana as
before).
## What's NOT here
- `brouter:` service on the flagship is intentionally left in place
(removed in section 7.5 after the 48 h soak window post-cutover).
- Observability (section 6) — Prometheus scrape + Loki shipping from
the dedicated host — comes in a follow-up PR.
- Cutover itself (section 7) — flip `BROUTER_URL`, verify, remove the
flagship brouter — is an operator action gated on first-time
provisioning + smoke testing.
## Verification
`pnpm typecheck && pnpm lint && pnpm test` all clean; planner build
passes (the CI regression from #286 was fixed in #290).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
46 lines
2 KiB
Docker
46 lines
2 KiB
Docker
FROM eclipse-temurin:11-jre-jammy
|
|
|
|
WORKDIR /brouter
|
|
|
|
# Download latest BRouter release
|
|
ARG BROUTER_VERSION=1.7.8
|
|
RUN apt-get update && apt-get install -y --no-install-recommends wget unzip curl \
|
|
&& wget -q "https://github.com/abrensch/brouter/releases/download/v${BROUTER_VERSION}/brouter-${BROUTER_VERSION}.zip" \
|
|
&& unzip "brouter-${BROUTER_VERSION}.zip" \
|
|
&& mv "brouter-${BROUTER_VERSION}"/* . \
|
|
&& rmdir "brouter-${BROUTER_VERSION}" \
|
|
&& rm "brouter-${BROUTER_VERSION}.zip" \
|
|
&& apt-get purge -y wget unzip && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user and directories for segments and profiles
|
|
RUN addgroup --system app && adduser --system --ingroup app app \
|
|
&& mkdir -p /data/segments /data/profiles
|
|
|
|
# Copy default profiles from release and rename JAR for simpler CMD
|
|
RUN cp -r profiles2/* /data/profiles/ 2>/dev/null || true \
|
|
&& mv brouter-*-all.jar brouter.jar
|
|
|
|
# Patch profiles to include extra tags in WayTags output for visualization
|
|
# Each tag needs its own assign statement to appear in tiledesc WayTags
|
|
RUN for f in /data/profiles/*.brf; do \
|
|
if grep -q "dummyUsage" "$f"; then \
|
|
grep -q "maxspeed" "$f" || sed -i '/assign dummyUsage/a assign dummyUsage2 = maxspeed=' "$f"; \
|
|
grep -q "tracktype" "$f" || sed -i '/assign dummyUsage/a assign dummyUsage3 = tracktype=' "$f"; \
|
|
elif grep -q "context:node" "$f"; then \
|
|
sed -i '/---context:node/i assign dummyUsage2 = maxspeed=\nassign dummyUsage3 = tracktype=' "$f"; \
|
|
fi; \
|
|
done
|
|
|
|
USER app
|
|
EXPOSE 17777
|
|
|
|
# JAVA_OPTS can be overridden at runtime (e.g., `-Xmx8g` for planet-scale).
|
|
# The default keeps the flagship's single-instance footprint small.
|
|
ENV JAVA_OPTS="-Xmx1024M -Xms256M -Xmn64M"
|
|
|
|
# BRouter server: <segmentdir> <profiledir> <customprofiledir> <port> <maxthreads>
|
|
# Shell form so $JAVA_OPTS expands at container start.
|
|
CMD java $JAVA_OPTS -DmaxRunningTime=300 -cp brouter.jar \
|
|
btools.server.RouteServer \
|
|
/data/segments /data/profiles /data/profiles \
|
|
17777 4
|