garage44.eu/jeroen/cartopolis

logclone: git clone https://garage44.eu/jeroen/cartopolis.git

.. /docs/guides/server.md

raw

Self-hosted geo services (Overpass + Nominatim + 3DBAG)

Installing a server of your own is curl -fsSL https://cartopolis.org/server/install.sh | sh (or | sh -s maps.example.org; the same install.sh sits in the unpacked download). It installs to /opt/cartopolis-server under systemd, owned by the user cartopolis. Updates are the program's own (crates/server/src/update.rs): a release signed by the maintainer's key appears on the Admin page, and an admin installs it there; [update] check = false turns looking off, [update] url names another source. It asks for the first admin (later: sudo -u cartopolis ./cartopolis-server create-admin in that directory), and adds the address to Caddy when Caddy is installed. The settings are /opt/cartopolis-server/cartopolis.toml; the keys are those of the simulator (crates/simulator/src/config.rs) with atlas's under [atlas] (crates/atlas/src/config.rs). The map data is made from the website's Admin ▸ Data, or with the atlas run below. Build the download from source with deploy/build/server-package.sh.

Overpass and Nominatim are retired (2026-11-11). Atlas answers both from a Geofabrik OpenStreetMap extract it downloads itself: the per-cell layers tall, street, transit, shops, speeds and osmbuildings, and place search at /geocode/search and /geocode/reverse from its geocoder dataset. On a new server, skip the overpass and nominatim services and their imports below (sections 4–7) and run, after atlas is up:

atlas run --out /data/3dbag/site --name nederland --bbox 13000 306000 278000 620000 \
  --datasets tall,street,transit,shops,speeds,osmbuildings,geocoder

about five hours on 8 cores at low priority, 4.3 GB of memory at peak, a 1.4 GB extract and 9.9 GB of cells (7.9 GB of it buildings) on 2026-11-11; route /geocode/* to atlas in Caddy. The simulator tells its clients where these are (GET /api/services, docs/notes/the-server-stack.md).

A new server is one program: cartopolis-server (crates/server) runs the simulator and atlas from one cartopolis.toml (atlas's keys under [atlas]; set public_base_url, and web_root to the built web UI) and serves the whole site on its HTTP listener, 127.0.0.1:4748 by default. HTTPS stays Caddy's — one machine often serves more than one site on port 443:

maps.example.org {
	reverse_proxy 127.0.0.1:4748
}

The rest of this guide is kept for the history until it is rewritten.

Operational guide for the example.com server: a Docker Compose stack running a local Overpass API and Nominatim instance, each seeded with the Netherlands OSM extract, behind a Caddy reverse proxy with automatic TLS.

The cartopolis client streams building footprints and POI layers from Overpass (overpass_query in crates/cartopolis/src/systems/map/osm_buildings.rs). The public overpass-api.de endpoint rate-limits (429/504) under the client's streaming load, so we run our own instance and point the client at it with CARTO_OVERPASS_URL. Nominatim provides geocoding / reverse-geocoding for the same region.

Why Docker. The upstream images (wiktorn/overpass-api, mediagis/nominatim) bundle the import and a diff-update mechanism, so the whole deployment — and its maintenance — reduces to a few environment variables. The host OS only has to run Docker. (We use the updates for Overpass and deliberately not for Nominatim — see Static vs. updating.)

Host

ProviderOVH VPS-4 (KVM)
OSUbuntu 26.04 LTS
CPU / RAM8 vCores / 22 GB
System disk/dev/sda 200 GB → /
Extra volume/dev/sdb 200 GB → /data (ext4)
Domainexample.com (apex, www, overpass → the VPS)
Public IPs<VPS_IPV4> / <VPS_IPV6>

Everything data-heavy (Docker images, both databases) lives on the /data volume, keeping the OS disk lean. The Nominatim import cannot fill the root filesystem.

Provisioning (what to order)

Order an OVH VPS with these choices (each has a one-line rationale; adjust for your region and data):

First access. The delivery email (or OVH Manager → …→ VPS) gives the IP and credentials. SSH in as the distro user (ssh ubuntu@<IP>) or with the emailed root password; the Manager's KVM console is the fallback if SSH fails. Then harden before anything else:

sudo apt-get update && sudo apt-get upgrade -y
# add your key (from your laptop):  ssh-copy-id ubuntu@<IP>
# then in /etc/ssh/sshd_config set: PasswordAuthentication no; sudo systemctl restart ssh

Layout

/data                       # OVH block volume (network-attached)
├── docker/                 # Docker data-root (images + named volumes)
└── stack/
    ├── docker-compose.yml   # overpass + nominatim + caddy
    ├── Caddyfile            # reverse proxy + TLS
    └── .env                 # NOMINATIM_PASSWORD (secret, chmod 600, not in git)

/srv/nominatim/pgdata       # root NVMe — Nominatim's PGDATA, bind-mounted

Named volumes (overpass_db, caddy_data, caddy_config) all resolve under /data/docker/volumes.

Nominatim's database is the exception, and deliberately so. /data is OVH's additional volume, which is network-attached: measured at ~240 random 8 KB IOPS against ~8,000 on the root NVMe. A geocoding search touches thousands of random pages, so a cold street-and-city lookup took 4–10 s there and tripped Nominatim's own 10 s timeout (HTTP 503, Query took too long to process.), while the same statement served from cache took 15 ms. Docker's data-root lives on /data, so a named volume cannot be moved off it — the PGDATA is a bind mount to /srv/nominatim/pgdata on the root disk instead. See docs/notes/geocoding-latency.md for the numbers and for the several plausible causes that turned out not to be it.

Executing the steps

Run steps 1–5 in order over SSH as the ubuntu user (which has passwordless sudo). After each step, confirm its ✓ check before moving on. Re-running a step is safe (idempotent) except the mkfs in step 1, which erases the volume.

Fill in these values first and substitute them everywhere below — including inside the docker-compose.yml and Caddyfile:

PlaceholderMeaningWhere to get it
<VPS_IPV4> / <VPS_IPV6>the VPS public IPsdelivery email / OVH Manager → …→ VPS
example.comyour domain (apex + www, overpass subdomains)your registrar
you@example.comACME contact for Let's Encryptyour email
region extractGeofabrik .osm.pbf + …-updates/ URLdownload.geofabrik.de (here: europe/netherlands)

Two things are not pure SSH commands and act as gates:

1. Extra volume → /data

The 200 GB volume ships blank. First confirm the target device — the extra volume is the one with no filesystem and no mountpoint (here /dev/sdb; it may differ). mkfs erases whatever it points at, so never run it against the system disk (/dev/sda*, mounted at /):

lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT   # pick the blank disk: no FSTYPE, no MOUNTPOINT
DEV=/dev/sdb                            # <-- set to the confirmed device

Then format and mount it by UUID (with nofail so a missing volume never blocks boot):

sudo mkfs.ext4 -L geodata "$DEV"
UUID=$(sudo blkid -s UUID -o value "$DEV")
sudo mkdir -p /data
echo "UUID=$UUID /data ext4 defaults,discard,nofail 0 2" | sudo tee -a /etc/fstab
sudo mount -a
df -h /data

✓ check: df -h /data shows the ~200 GB volume mounted at /data.

2. Docker (data-root on /data)

Ubuntu's own packages avoid the "Docker's apt repo has no dist for 26.04 yet" problem on a fresh release:

sudo apt-get update
sudo apt-get install -y docker.io docker-compose-v2

# point the data-root at the big volume BEFORE pulling anything
sudo systemctl stop docker docker.socket
sudo mkdir -p /data/docker
echo '{ "data-root": "/data/docker" }' | sudo tee /etc/docker/daemon.json
sudo systemctl start docker

sudo usermod -aG docker ubuntu
sudo docker info | grep 'Docker Root Dir'   # -> /data/docker

The group membership only applies to a new login shell. Open a fresh SSH session before the later docker commands, or prefix them with sudo in this one.

✓ check: Docker Root Dir prints /data/docker.

3. DNS

Manual step (OVH panel or API). In the OVH DNS zone (Web Cloud → Domain names → example.com → DNS Zone), point the names at the VPS. @ and www replace OVH's parking records; overpass is new:

SubdomainTypeTarget
@A<VPS_IPV4>
@AAAA<VPS_IPV6>
wwwA / AAAAsame
overpassA / AAAAsame

Verify before starting Caddy (Let's Encrypt needs the names to resolve):

dig +short overpass.example.com     # must print <VPS_IPV4> before continuing

✓ check (hard gate): dig returns your <VPS_IPV4> for overpass, apex and www. Do not start Caddy until it does.

Nominatim's subdomain is not created yet — see step 6.

4. The stack

/data/stack/docker-compose.yml and /data/stack/Caddyfile are the whole deployment. Generate the Nominatim password once:

sudo mkdir -p /data/stack && sudo chown "$USER" /data/stack
echo "NOMINATIM_PASSWORD=$(openssl rand -hex 24)" > /data/stack/.env
chmod 600 /data/stack/.env

docker-compose.yml

Key choices, encoded as env vars:

name: geo

services:
  overpass:
    image: wiktorn/overpass-api:v0.7.62.9
    container_name: overpass
    restart: unless-stopped
    environment:
      OVERPASS_META: "no"
      OVERPASS_MODE: init
      OVERPASS_PLANET_URL: https://download.geofabrik.de/europe/netherlands-latest.osm.pbf
      OVERPASS_PLANET_PREPROCESS: 'mv /db/planet.osm.bz2 /db/planet.osm.pbf && osmium cat -o /db/planet.osm.bz2 /db/planet.osm.pbf && rm /db/planet.osm.pbf'
      OVERPASS_DIFF_URL: https://download.geofabrik.de/europe/netherlands-updates/
      OVERPASS_RULES_LOAD: "10"
      OVERPASS_UPDATE_SLEEP: "86400"
      OVERPASS_ALLOW_DUPLICATE_QUERIES: "yes"
    volumes:
      - overpass_db:/db
    ports:
      - "127.0.0.1:12345:80"
    networks: [geonet]

  nominatim:
    image: mediagis/nominatim:5.3.2
    container_name: nominatim
    restart: unless-stopped
    environment:
      PBF_URL: https://download.geofabrik.de/europe/netherlands-latest.osm.pbf
      IMPORT_STYLE: address
      NOMINATIM_PASSWORD: ${NOMINATIM_PASSWORD}
      # Static, query-only. Drops the replication block in the image's
      # /app/start.sh entirely — including an unconditional
      # `nominatim replication --init` that otherwise runs on EVERY boot even
      # with UPDATE_MODE unset. See "Static vs. updating" below.
      FREEZE: "true"
      # Query-instance tuning. The image's defaults are import defaults: 2 GB of
      # shared_buffers cannot hold search_name (3.5 GB) + its GIN indexes, and
      # every miss then costs a random read off a 240-IOPS volume. 10 GB of
      # maintenance_work_mem is likewise only useful during the import.
      POSTGRES_SHARED_BUFFERS: 8GB
      POSTGRES_MAINTENANCE_WORK_MEM: 1GB
      POSTGRES_EFFECTIVE_CACHE_SIZE: 18GB
      # Runs `nominatim admin --warm` before serving, so the first real user is
      # not the one who pays for a cold cache after a restart.
      WARMUP_ON_STARTUP: "true"
    volumes:
      # Bind mount, not a named volume: Docker's data-root is on the slow /data
      # block volume. See "Layout" above.
      - /srv/nominatim/pgdata:/var/lib/postgresql/16/main
      # No nominatim_flatnode mount: the node cache is only read by osm2pgsql
      # during import and diff updates, never by queries, and it is ~105 GB.
    shm_size: 2g
    ports:
      - "127.0.0.1:8080:8080"
    networks: [geonet]

  caddy:
    image: caddy:2
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config
    networks: [geonet]

networks:
  geonet:

volumes:
  overpass_db:
  caddy_data:
  caddy_config:

Caddyfile

{
	email you@example.com
}

overpass.example.com {
	reverse_proxy overpass:80
}

# nominatim.example.com {
# 	reverse_proxy nominatim:8080
# }

example.com, www.example.com {
	header Content-Type "text/plain; charset=utf-8"
	respond "example.com — self-hosted geo services.

Overpass API : https://overpass.example.com/api/interpreter
" 200
}

Write the two files

Save the two blocks above to /data/stack/, substituting your domain and email first. Use a quoted heredoc (<<'EOF') so ${NOMINATIM_PASSWORD}, the quotes, and the && in the preprocess command are written literally instead of being expanded by the shell:

cat > /data/stack/docker-compose.yml <<'EOF'
# ...paste the docker-compose.yml block above, verbatim...
EOF

cat > /data/stack/Caddyfile <<'EOF'
# ...paste the Caddyfile block above, with your domain + email...
EOF

cd /data/stack && docker compose config --quiet && echo "compose OK"

✓ check: docker compose config reports no errors (compose OK), and ls /data/stack shows .env, docker-compose.yml, Caddyfile.

5. Start it — long imports in screen

The two imports run far longer than an SSH session (Overpass ~20–60 min, Nominatim ~1–3 h). The work happens inside the containers (managed by the Docker daemon, so it survives disconnects); we just watch the logs from a screen session so progress is easy to follow and reattach to.

Run the two imports one at a time, not concurrently. Both write to the same /data volume; run together they saturate the disk and each crawls (Overpass's bzip2 passes and Nominatim's osm2pgsql compete for I/O). Import Overpass to healthy first, then start Nominatim.

cd /data/stack

# Caddy first — obtains Let's Encrypt certs (needs step 3 DNS to resolve):
docker compose up -d caddy

# Overpass import — run it ALONE:
docker compose up -d overpass
screen -dmS overpass bash -c 'cd /data/stack && docker compose logs -f overpass'

Wait for Overpass to go healthy (the loop below), then start Nominatim:

docker compose up -d nominatim
screen -dmS nominatim bash -c 'cd /data/stack && docker compose logs -f nominatim'

Follow / detach:

screen -ls                 # list sessions
screen -r overpass         # attach   (detach again: Ctrl-A then D)
docker compose ps          # container + health status

While importing, https://overpass.example.com/api/interpreter returns 502 (backend not ready). Block until the container's health flips to healthy:

# waits until Overpass has finished importing:
until [ "$(sudo docker inspect -f '{{.State.Health.Status}}' overpass)" = healthy ]; do
  sleep 30; echo 'overpass still importing…'
done
echo 'overpass ready'

If Overpass stays unhealthy after the import and every query returns an HTML page with open64: 13 Permission denied /db/db/osm3s_osm_base, the /db volume directory is drwx------ (owner-only) so the web process (www-data) can't traverse to the dispatcher socket. Fix once — it persists on the volume, and a restart won't re-import (init is skipped once /db/init_done exists):

docker exec -u root overpass chmod o+rx /db
docker restart overpass

Nominatim has no healthcheck; it is ready when a local query returns results (the smoke test in step 6). Then verify end-to-end:

# apex landing page (works as soon as Caddy has its cert)
curl -s https://example.com

# Overpass through the public TLS endpoint:
curl 'https://overpass.example.com/api/interpreter' \
  --data 'data=[out:json][timeout:25];way["building"](52.09,5.11,52.10,5.12);out geom;'

✓ check: the Overpass query returns JSON containing elements (no 502).

6. Enable Nominatim publicly (after import)

Nominatim listens on 127.0.0.1:8080 only. To expose it:

  1. Add DNS records nominatim → <VPS_IPV4> / <VPS_IPV6> (same as overpass).
  2. Uncomment the nominatim.example.com block in the Caddyfile.
  3. Apply it by recreating Caddy — not caddy reload. The Caddyfile is bind-mounted as a single file; an editor or sed -i writes a new inode, which the running container doesn't see, so reload reports "config is unchanged". Recreating re-reads the file and fetches the cert:
docker compose up -d --force-recreate caddy

Local smoke test meanwhile:

curl 'http://127.0.0.1:8080/search?q=Dam,Amsterdam&format=jsonv2'
curl 'http://127.0.0.1:8080/reverse?lat=52.373&lon=4.892&format=jsonv2'

7. Point the client at it

The client (overpass_query in crates/cartopolis/src/systems/map/osm_buildings.rs) defaults to the self-hosted endpoint (DEFAULT_OVERPASS_URL), so a plain run already uses it:

cargo run -p cartopolis

Override with CARTO_OVERPASS_URL to point elsewhere — e.g. back to the public API:

CARTO_OVERPASS_URL=https://overpass-api.de/api/interpreter cargo run -p cartopolis

Against a dedicated instance you can also lower OVERPASS_THROTTLE (osm_buildings.rs, the 800 ms politeness delay) for faster streaming.

Nominatim is wired the same way: geo-search (geo_nav.rs) and bookmark reverse-geocoding (bookmarks.rs) both use nominatim_base_url(), which defaults to DEFAULT_NOMINATIM_URL and is overridable with CARTO_NOMINATIM_URL (e.g. https://nominatim.openstreetmap.org).

8. The Dutch map layers (self-hosted static tiles)

For the Netherlands we serve building geometry, building facts and surveyed street objects from our own host instead of guessing them from OSM. The live source APIs are slow and rate-limited, so — like Overpass — we host the result ourselves. Unlike Overpass it is static, download-once data: no database, no diffs, just preprocessed files behind Caddy. Currently the city of Groningen is covered.

Six datasets, all landing in one tree and all served by the same Caddy site:

PathSourceWhat the client does with it
water/Kadaster 3D basisvoorziening Waterdeel_vlakthe level each canal, river and pond stands at (water_levels.rs)
buildings/3DBAG WFS BAG3D:lod12footprints + heights, Overpass-shaped — the fallback tier (osm_buildings.rs)
lod22/3DBAG CityJSON LoD2.2real roof and wall geometry, as triangles (lod22.rs)
bag/PDOK BAG WFS + the RCE heritage layersyear, use, floor areas, addresses, entrance points, monuments (building_facts.rs)
bgt/PDOK BGT OGC APIsurveyed trees, lampposts, benches, fences, hedges, paving (surveyed.rs)
dikes/PDOK IMWA waterkeringthe dikes, dunes and dams, as named lines (dikes.rs)

Where the extractors live

In atlas, crates/atlas/src/pipeline/. They were Python scripts under tools/, run by hand over ssh; from 2026-08 they were TypeScript in a separate repository; since 2026-09 they are Rust in the cartopolis_atlas crate. Two ways in, one code path. The Data tab of the atlas web UI at cartopolis.org/admin: an operator picks an area, picks datasets, presses Start and watches the log; the coverage panel says what the tree currently holds before anything is run. Or a shell, with no web UI and no simulator:

atlas run --out /tmp/site --area groningen --datasets buildings,bag
atlas run --out /tmp/site --name delfzijl --bbox 253000 592000 258000 597000 --datasets bgt

--bbox is RD New (EPSG:28992) as xmin ymin xmax ymax, not degrees; --name is the coverage name stamped into every manifest; leaving out --datasets runs all six.

The reason to know where they live is the other direction: their output formats are parsed in the client — lod22.rs, building_facts.rs, surveyed.rs, osm_buildings.rs, dikes.rs and water_levels.rs each read one of these shapes. Writer and reader are in one repository now but in different crates, with no shared type: atlas writes through serde_json::Value, so a renamed key still compiles on both sides and reaches a client as an empty layer. Change a wire format in atlas and its parser in the same commit.

docs/notes/where-the-map-data-is-built.md has both moves, the equivalence checks against the code each replaced, and what is still done by hand.

The tree on the box

/data/3dbag/site               # OUTPUT, bind-mounted read-only into caddy
├── coverage.json              # which z14 cells this host serves (client routing)
├── buildings/14/{x}/{y}.json  # per-cell Overpass-shaped buildings
├── lod22/14/{x}/{y}.json      # per-cell LoD2.2 triangle meshes (+ .bin, .bin.gz)
├── bag/14/{x}/{y}.json        # per-cell building facts  (+ .places.json)
├── bgt/14/{x}/{y}.json        # per-cell street objects  (+ .surfaces.json)
├── dikes/14/{x}/{y}.json      # per-cell flood defences
└── water/14/{x}/{y}.json      # per-cell water levels

(Every dataset but buildings keeps its own <dataset>/coverage.json.)

Two of the datasets write two files per cell, and it is the same reason both times: the heavy half is wanted by a different consumer from the light half. bag/{y}.places.json holds the addresses (2.0 MB in the densest Groningen cell, against 0.53 MB of buildings) which only building_facts reads, while lod22 fetches the buildings file inside its own mesh job. bgt/{y}.surfaces.json holds the paving, which is the second-heaviest thing the client streams.

The old /data/3dbag/venv and /data/3dbag/bin are the retired Python. They can go once atlas has run a full city; keeping them costs nothing and is the fallback until then.

Serving — the caddy service bind-mounts /data/3dbag/site:/srv/3dbag:ro and the Caddyfile has:

3dbag.cartopolis.org {
	root * /srv/3dbag
	encode gzip
	file_server {
		precompressed br gzip
	}
	header Access-Control-Allow-Origin "*"
	header /coverage.json Cache-Control "public, max-age=3600"
	header /buildings/* Cache-Control "public, max-age=86400"
	header /lod22/* Cache-Control "public, max-age=86400"
	header /bag/* Cache-Control "public, max-age=86400"
	header /bgt/* Cache-Control "public, max-age=86400"
	header /dikes/* Cache-Control "public, max-age=86400"
}

precompressed gzip is load-bearing for the LoD2.2 binary cells (lod22/14/{x}/{y}.bin): encode gzip compresses only a default list of text content types and a .bin goes out as application/octet-stream, so it is served compressed only because atlas writes x.bin.gz beside it.

br first: atlas writes an x.br beside every served file of 1 KB or more, 30–35 % smaller than gzip, and a client that does not accept Brotli gets the .gz or the on-the-fly gzip as before (docs/notes/atlas.md). Caddy checks only that a sidecar exists, so switch br on only once the deployed atlas writes them; a tree from an older atlas is backfilled once with brotli -q 10 over every .json and .bin.

Adding the bind mount needs a recreate (not reload): docker compose up -d --force-recreate caddy. A DNS record 3dbag → <VPS_IPV4>/<VPS_IPV6> must exist (Let's Encrypt).

Smoke test: curl --compressed https://3dbag.cartopolis.org/coverage.json.

The pipeline service

The pipelines are served by atlas: /api/pipeline/* routes (crates/atlas/src/api.rs) inside cartopolis-atlas.service, which replaced the Bun cartopolis-pipeline.service in 2026-09. It is a native binary under systemd, the same shape as cartopolis-sim.service: deploy-atlas.yml (manual) publishes it into /data/cartopolis/atlas and touches restart.stamp, and cartopolis-atlas-reload.path on the host does the restart. It runs as its own user, cartoatlas, in group ubuntu with umask 0002, because the site tree belongs to ubuntu. Its configuration is /data/cartopolis/atlas/atlas.toml; unknown keys are refused:

listen = "172.17.0.1:4749"
data_dir = "/data/cartopolis/atlas/data"
upstream_concurrency = 3
site_dir = "/data/3dbag/site"                           # the tree the pipelines write
admin_api = "http://172.17.0.1:4748"                    # the simulator, asked who is an admin

It listens on the docker0 gateway (172.17.0.1:4749), and Caddy sends the web UI's /api/pipeline/* calls there — matched before any /api/* block that goes to the simulator, or every call lands on the simulator and 404s. The web UI itself is static files at the site root, https://cartopolis.org/. The pipeline runs one job at a time.

It authorises nothing itself: each request's bearer goes to the simulator's /api/admin/me (admin_api, crates/atlas/src/auth.rs), so there is one list of operators and revoking somebody there revokes them here.

The unit files are in deploy/ (cartopolis-atlas.service and its reload pair), and docs/notes/atlas.md has the design.

A refresh replaces a dataset's coverage, it does not add to it. Each extractor rewrites the whole manifest for its dataset, so extracting a second city takes the first one's place — the first city's cell files stay on disk and the client simply stops being told about them. The web UI warns before doing it. Until that is fixed, one covered area per dataset is the rule.

Client wiring: the client fetches covered z14 cells from CARTO_3DBAG_URL (default https://3dbag.cartopolis.org) and falls back to Overpass (OSM) on a 404 — see osm_buildings.rs. Attribution (coverage.json.attribution, CC BY 4.0) is shown in the client.

9. VersaTiles vector basemap (self-hosted)

The client's default basemap (DEFAULT_TILE_URL_TEMPLATE, and the CARTO_TILE_URL the CI scene smoke pins) is a self-hosted mirror of the VersaTiles planet build — Shortbread-schema MVT, every zoom, worldwide. Routing needs a vector source, so this is not just a cosmetic basemap: against a raster template the planner refuses to plan.

Like 3DBAG it is static, download-once data — but as a single 62 GB archive rather than a file tree, served by the versatiles binary rather than by Caddy.

The archive. One file, /srv/versatiles/osm.versatiles:

# 62 GB over ~35 min at 40 MB/s. Run it in `screen`, not nohup, and use a single
# `wget -c` writer — a second one racing the same path corrupts the archive.
screen -S tiles
cd /srv/versatiles
wget -c https://download.versatiles.org/osm.versatiles 2>&1 | tee download.log

Budget for it: the box's root volume is 193 GB and this is a third of it. Refreshing to a newer planet means re-downloading the whole archive — there are no diffs — so keep enough headroom to hold the new one beside the old if you want a swap with no downtime.

The service. The latest-scratch image has no shell, hence the explicit entrypoint; the [osm] prefix names the source, which is what puts osm in the tile path. No published ports — it is reachable only through Caddy on geonet:

  tiles:
    image: ghcr.io/versatiles-org/versatiles:latest-scratch
    container_name: tiles
    restart: unless-stopped
    entrypoint: /app/versatiles
    command: serve -i 0.0.0.0 -p 8080 "[osm]/data/osm.versatiles"
    volumes:
      - /srv/versatiles/osm.versatiles:/data/osm.versatiles:ro
    networks: [geonet]

Serving — a plain proxy, because the versatiles server already sets CORS (*) and a long Cache-Control itself:

tiles.cartopolis.org {
	reverse_proxy tiles:8080
}

A DNS record tiles → <VPS_IPV4>/<VPS_IPV6> must exist for Let's Encrypt.

Smoke test — a tile is a gzipped protobuf, so check the status and size, not the body:

curl -sI https://tiles.cartopolis.org/tiles/osm/14/8490/5319 | head -3

Client wiring: https://tiles.cartopolis.org/tiles/osm/{z}/{x}/{y} is the default; CARTO_TILE_URL overrides it and CARTO_TILE_FORMAT forces vector|raster when a template's kind can't be inferred. A scripted run (--shot / cargo shots) never sees the server handshake that would supply one, which is why docs/shots.toml pins tile_url — the built-in fallback is the raster basemap.

10. PDOK AHN height proxy (web build only)

The height layer (systems::height) reads AHN elevation rasters straight from https://service.pdok.nl on native. The browser build can't: PDOK is a third party and its CORS rules are not ours to negotiate, so the wasm client asks its own origin for /up/ahn/… (http::upstream_url) and Caddy forwards it. Trunk.toml provides the same path as a [[proxy]] in dev, so one code path works in both.

This block lives on the web client's site, beside the identical /up/nomads/* proxy the globe's cloud cover needs:

handle_path /up/ahn/* {
	reverse_proxy https://service.pdok.nl {
		header_up Host service.pdok.nl
		header_up User-Agent "cartopolis/0.2 (https://code.garage44.eu/jeroen/cartopolis; jvanveen@protonmail.com)"
	}
}

The User-Agent is not decoration: a browser fetch silently drops the header, and putting it back here is what lets PDOK see who is calling a public service they run for free. Nothing is cached or stored on our side — the layer is off by default in the client for the same reason.

Maintenance

Routine upkeep is mostly automatic. What's left is occasional and change-driven.

Diff updates — Overpass applies them daily (OVERPASS_UPDATE_SLEEP), nothing to schedule. Nominatim does not update: it runs frozen, on purpose.

Static vs. updating

Nominatim runs static (FREEZE=true, no flatnode volume). Reversing that is a full re-import, so the trade is worth understanding before you change it.

What the flatnode file is. A node cache osm2pgsql writes during import, sized by the global OSM node-ID space rather than the extract — so a Netherlands-only import still produced 105 GB, over half of /data. It is read only by osm2pgsql, during import and while applying diffs. Queries never touch it; they hit Postgres. A frozen instance therefore has no reader for it at all.

Measured on this host (2026-07-30): deleting it freed 105 GB and cost ~30 s of downtime. Search, reverse and the public route all returned 200 immediately after, and again after a forced restart with the file absent.

Why FREEZE=true is required, not cosmetic. The image's /app/start.sh runs nominatim replication --init unconditionally whenever REPLICATION_URL is set and FREEZE is not — outside the UPDATE_MODE branches, so it fires on every boot even when no updater is configured. FREEZE=true drops that whole block. Without it, a restart eventually reaches for a file that is no longer there. Confirm after a restart:

docker logs --since 5m nominatim | grep -i replication   # expect: replicationpid=0

What you give up. Incremental updates, permanently, without re-importing. Geocoding results are a snapshot of the extract's import date. For cartopolis that is acceptable: place names and addresses move slowly, and the client's failure mode is a missing search result, not incorrect data.

To re-enable updates (~105 GB and a 1–3 h re-import):

  1. Drop FREEZE, restore REPLICATION_URL and the nominatim_flatnode volume plus its /nominatim/flatnode mount
  2. Set UPDATE_MODE=continuous — without it the container still never updates, which is exactly how this instance sat "configured for replication" for weeks while doing nothing
  3. Empty /srv/nominatim/pgdata and re-import: the flatnode cannot be reconstructed from an existing database

Check whether an instance is actually updating (not merely configured to):

docker exec nominatim psql -U nominatim -d nominatim -tAc 'select * from import_status;'
stat -c %y /data/docker/volumes/geo_nominatim_flatnode/_data/flatnode.file

An empty import_status and a flatnode mtime equal to the import date mean replication never ran.

Remaining upkeep:

Troubleshooting

Isolate the layer:

Security notes