feat(deploy): bake custom_models into a thin GraphHopper image#75
Merged
Conversation
Replace the host-side bind mount of `backend/custom_models/` with a custom GH image that COPYs the dir at build time. CD builds and pushes `ghcr.io/cafca/beebeebike-graphhopper:latest` alongside the backend image; `compose.prod.yml` pulls it. Routing rules now ship atomically with `docker compose pull`, no scp dance, no separate sync path. CD also gains a post-deploy probe: if the freshly-started GH container logs `Profile 'X' does not match` (i.e. the new image carries different priority/speed/distance_influence rules from what the cached graph was baked against), CD wipes `data/osm/berlin/graphhopper` and reimports. Cache is preserved across normal backend-only deploys. Supersedes #73 — the host-side custom_models scp + bind mount approach becomes unnecessary once the file lives inside the image that reads it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the host-side bind mount of
backend/custom_models/with a thin custom GraphHopper image that copies the directory in at build time. Routing rules now ship atomically withdocker compose pull— no host scp, no "did the file reach the server?" failure mode.CD also gains a post-deploy probe that wipes the GH cache only when actually needed (i.e. when the new image carries a different profile hash from the one baked into the existing graph cache).
Changes
backend/graphhopper.Dockerfile(new):```dockerfile
FROM israelhikingmap/graphhopper:latest
COPY backend/custom_models/ /custom_models/
```
compose.prod.yml: switch GH service toghcr.io/cafca/beebeebike-graphhopper:latest. Bind mount ofbackend/custom_modelsis unnecessary (file is in the image now)..github/workflows/cd.yml:docker compose up -d, sleep 12s and grep recent GH logs fordoes not match. If found → stop GH, wipedata/osm/berlin/graphhopper, restart for a fresh import. Otherwise leave the cache alone.Why
Today the routing rules live as a host file shipped via two separate paths (the scp
source:list, and acompose.prod.ymlbind mount). When PR #72 merged, both paths needed updates — neither got them — and prod GH crash-looped until the file was scp'd manually.With the rules inside the GH image:
docker pullan old tag and you get the matching custom model.docker compose pull && up -dis the only deploy verb again.Why the conditional cache wipe (vs. always wipe / vs. never wipe)
GraphHopper bakes the profile hash (priority/speed/distance_influence/turn_costs) into the imported graph. On boot it compares the configured hash to the stored one:
Profile 'bike' does not match.Always-wiping turns every backend-only deploy into a multi-minute GH outage. Never-wiping breaks deploys that change the profile. The crash-loop signature is unambiguous, so detecting it post-
up -dis reliable and lets the common path (model unchanged) stay fast.Notes for reviewers
israelhikingmap/graphhopper:latestbase is pinned tolatestto match current behavior; consider pinning to a tag in a follow-up.graphhopper_config.ymlstays host-mounted because it changes more often than custom models and we don't want a CD round trip for config-only edits. Could revisit later.Test plan
Profile hash mismatch detected).