I managed to get OSM tile server stack working on my laptop:
Here are a couple useful pages I read during my research:
- Switch2OSM – The Basics – explanation of some of the concepts in a way I could understand.
- Switch2OSM – serving tiles using a Docker container – good explanation of how to do what I write up below.
- openstreetmap-tile-server README – much more detail than this blog post.
- Location Guard Firefox Plugin – allows setting a hard-coded location instead of sharing your real location.
- Implementing Vector Tile Support in Libshumate – explanation of the ideas from James Westman
To run these commands you will need Docker, and hopefully nothing much else.
Download the data
I downloaded the UK data like this:
You can find downloads for other regions at download.geofabrik.de/
Then I ran an import, which converts the PBF data into tiles that can be shown in a UI:
docker volume create openstreetmap-data docker volume create openstreetmap-rendered-tiles docker run \ -v $PWD/great-britain-latest.osm.pbf:/data.osm.pbf \ -v openstreetmap-data:/var/lib/postgresql/12/main \ -v openstreetmap-rendered-tiles:/var/lib/mod_tile \ -e THREADS=24 \ overv/openstreetmap-tile-server:1.3.10 \ import
(Change “great-britain” to match what you downloaded.)
On my quite powerful laptop this took 39 minutes to run.
Run the tile server
Finally, I launched the server:
(Make sure you’ve done the “Import it” step first.)
docker run \ -p 8080:80 \ -v openstreetmap-data:/var/lib/postgresql/12/main \ -v openstreetmap-rendered-tiles:/var/lib/mod_tile \ -e THREADS=24 \ -e ALLOW_CORS=enabled \ -d overv/openstreetmap-tile-server:1.3.10 \ run
This should launch the docker container in the background, which you can check with docker ps.
It was quite unresponsive at first, but once it had cached the tiles I was looking at, it was very smooth.