services: maptool: # "./build", not ".": the compose file's own context ("." would mean # the symlink's directory, /srv/podman/maptool/ — see docs/deployment.adoc) # is one level above where the actual checkout (and its Dockerfile) # lives since the previous commit moved it into build/. Volume paths # below resolve against that same symlink directory too, but a relative # *build context* specifically needs pointing at build/ itself — the # gap this fixes: production's compose up --build failed outright # ("lstat .../maptool/Dockerfile: no such file or directory") until this # was caught, since only the volume-path resolution got dry-run tested # before the previous commit shipped, not this one. build: ./build image: maptool:latest restart: unless-stopped ports: - "4567:4567" environment: # "[::]", not "0.0.0.0": binding the IPv6 wildcard also accepts IPv4 # connections (dual-stack is the Linux default), so this covers both # without a second listener. Puma's bind URL needs the brackets around # a literal IPv6 address (config/puma.rb interpolates this as-is). BIND_HOST: "[::]" RACK_ENV: production # Read from .env (docker compose loads it automatically) — not # committed, see docs/deployment.adoc. SESSION_SECRET: ${SESSION_SECRET:?SESSION_SECRET is required, see docs/deployment.adoc} GITEA_OAUTH_CLIENT_ID: ${GITEA_OAUTH_CLIENT_ID:?GITEA_OAUTH_CLIENT_ID is required, see docs/deployment.adoc} GITEA_OAUTH_CLIENT_SECRET: ${GITEA_OAUTH_CLIENT_SECRET:?GITEA_OAUTH_CLIENT_SECRET is required, see docs/deployment.adoc} MAPTOOL_ALLOWED_GITEA_USER: ${MAPTOOL_ALLOWED_GITEA_USER:?MAPTOOL_ALLOWED_GITEA_USER is required, see docs/deployment.adoc} # Optional: blank disables the LiveTrack webhook endpoint rather than # failing to start, since it's not needed for the app's core function. LIVETRACK_WEBHOOK_SECRET: ${LIVETRACK_WEBHOOK_SECRET:-} # Optional: the home MQTT broker with the car's live data (GNSS # tracker, ITS-G5) — a read-only user; blank turns /api/live off. MQTT_URL: ${MQTT_URL:-} MQTT_USERNAME: ${MQTT_USERNAME:-} MQTT_PASSWORD: ${MQTT_PASSWORD:-} # Optional, only read by data/plugins/p4n2gpx/'s own p4n2gpx.rb (not # part of this repo — see docs/deployment.adoc) if that private # plugin is present; blank just means it fails with its own "could # not authenticate" error when run, same non-fatal-to-startup story # as the other optional secrets here. P4N_USER/P4N_PASSWORD alone # don't actually work here — park4night's login form is behind # invisible reCAPTCHA, which no browserless login can satisfy — so # P4N_SESSION_COOKIE (a real logged-in browser's session cookie, # copied out by hand and refreshed whenever it expires) is what # p4n2gpx.rb's make_session actually ends up using. P4N_USER: ${P4N_USER:-} P4N_PASSWORD: ${P4N_PASSWORD:-} P4N_SESSION_COOKIE: ${P4N_SESSION_COOKIE:-} # The kiwix service below, reached by its compose service name (both # are on the same default compose network) — port matches its own # --port=8080 in the command below. Not made conditional on the ZIM # actually being present: GET /api/kiwix pings it and just reports # unavailable if the container isn't up/reachable, same story as # every other optional-local-file feature (offline.pmtiles, etc). # Reached server-side only — production sits behind a reverse proxy # that only forwards to maptool itself, so app.rb's GET /kiwix/* # proxies to this instead of handing the browser this address. KIWIX_URL: "http://kiwix:8080" # The valhalla service below, same story as KIWIX_URL. VALHALLA_URL: "http://valhalla:8002" # Google Takeout exports (the "Saved" lists), mounted below; app.rb # imports a new one hourly. Remove both lines to turn it off. TAKEOUT_DIR: /app/takeout # Library sync (lib/maptool/sync.rb): the shared token on the server # and its clients; a client also has the server's URL (Sync button). SYNC_SERVER_URL: ${SYNC_SERVER_URL:-} SYNC_TOKEN: ${SYNC_TOKEN:-} # Only on a server with no reverse proxy in front (the car's): these # networks count as logged in. Never on one behind a proxy. TRUSTED_NETWORKS: ${TRUSTED_NETWORKS:-} # The car's server: the update button (lib/maptool/updater.rb). SELF_UPDATE: ${SELF_UPDATE:-} volumes: # Uploaded GPX files and the offline PMTiles extract — kept outside # the image so a rebuild/redeploy doesn't wipe them (see # docs/development.adoc for how the deploy job treats this # directory). A private plugin (app.rb's PLUGINS_DIRS) also belongs # under here, at data/plugins// — nothing further to mount, # this one bind already covers the whole data/ tree. An offline.pmtiles # build's own scratch work (Dir.mktmpdir, lib/maptool/pmtiles_builder.rb) # happens outside this mount, in the container's own filesystem — a # large country's .osm.pbf plus Planetiler's working set can be # several GB, worth knowing if the host is ever short on space there. # :z relabels the host directory for SELinux, since Podman on an # SELinux-enforcing host otherwise denies the container write access # to a bind-mounted directory regardless of Unix permissions — # harmless/ignored on a host without SELinux. Shared :z, not private # :Z: kiwix below mounts data/kiwix/wikipedia.zim too, and :Z here # recursively relabels that file to maptool's own private label, # locking kiwix out of it (and kiwix's :Z would do the same back). - ./data:/app/data:z # Where the Google Drive backup syncs the scheduled Takeout (a plain # directory; changed files get moved to ../../old/, so the bind stays # valid). Read-only. Shared :z like data/ above: brick enforces # SELinux and the backup tree is unlabeled_t, unreadable for a # container; the root sync job is unaffected by the relabel and new # files inherit the directory's label. # TAKEOUT_HOST_DIR: another server (the car's) points it at an empty dir. - ${TAKEOUT_HOST_DIR:-/srv/backup/gdrive/my-drive/current/Takeout}:/app/takeout:ro,z # Serves an offline Wikipedia ZIM for the popup's "Nearby on Wikipedia" # link (see docs/development.adoc for where to get one and drop it in — # same "not part of the repo, place it under ./data locally" story as # offline.pmtiles/terrain.pmtiles). On the default compose network (not # network_mode: "service:maptool" — KIWIX_URL above reaches it by this # service's own name), so maptool and kiwix stay independent containers. # Waits (entrypoint below) while data/kiwix/wikipedia.zim is missing or # empty — GET /api/kiwix just reports unavailable until it comes up. Not # a restart loop: on the car's server (host network, placeholder ZIM # until the map pull brings it) one restart a second meant a new veth # each time, and avahi's mDNS announcements of them filled the Pi's Wi-Fi. # # The volume binds the exact *file* path, not the data/kiwix/ directory — # deliberately, so data/kiwix/wikipedia.zim can be a symlink to wherever # the (large) real ZIM actually lives. A bind mount resolves a symlink at # its *source* path once, at mount time (plain mount(2) semantics, same # as Podman); a symlink sitting inside an already-mounted directory # doesn't get that treatment — the container would have to resolve it # itself, inside its own filesystem, where the host path it points to # doesn't exist. kiwix: image: ghcr.io/kiwix/kiwix-serve:3.8.2 restart: unless-stopped # No --port here: the image's own start.sh already prepends # --port=8080 (its default) before appending this command array, so # passing it again produced "Unexpected argument: --port=8080, # --port=8080, /data/wikipedia.zim" and kiwix-serve refused to start. # # --urlRootLocation=/kiwix makes every link/asset kiwix-serve itself # emits (search results, article pages, its CSS/JS) carry a /kiwix # prefix, matching where app.rb's GET /kiwix/* proxies requests in # from (confirmed against libkiwix's internalServer.cpp: it strips # this same prefix off incoming request paths, so both ends agree on # it) — no ports: mapping needed, nothing outside the compose network # ever talks to this container directly. # The image's own entrypoint (dumb-init, start.sh), after the wait. entrypoint: ["/usr/bin/dumb-init", "--", "sh", "-c", "until [ -s /data/wikipedia.zim ]; do sleep 60; done; exec /usr/local/bin/start.sh \"$$@\"", "kiwix"] command: ["--urlRootLocation=/kiwix", "/data/wikipedia.zim"] volumes: # :z, shared for the same reason as maptool's own ./data mount above. - ./data/kiwix/wikipedia.zim:/data/wikipedia.zim:z # Offline routing (docs/routing-design.adoc). Valhalla's own image (it # isn't packaged for Debian, so not in maptool's), running # data/routing/service.sh — bin/routing-service.sh, copied there by # maptool at boot so the two always match; the loop below waits for it # on a first start. Mounts the whole data/ (not just data/routing/) so it # can hard-link Geofabrik extracts from data/geofabrik_cache/ (a link # can't cross two bind mounts). Serves port 8002 on the compose network # only, maptool proxies to it. valhalla: image: ghcr.io/valhalla/valhalla:3.9.3 restart: unless-stopped depends_on: - maptool # maptool copies the deployed script here at boot. On a redeploy the # old copy is still there, so wait (up to a minute) for a fresh one; # a restart of this container alone runs the one that's there. command: ["bash", "-c", "s=/data/routing/service.sh; t=$$(date +%s); until [ -f $$s ] && { [ $$(stat -c %Y $$s) -ge $$t ] || [ $$(($$(date +%s) - t)) -gt 60 ]; }; do sleep 2; done; exec bash $$s"] volumes: # :z, shared for the same reason as maptool's own ./data mount above. - ./data:/data:z networks: default: enable_ipv6: true