basemaps
basemaps copied to clipboard
Generate tiles with Docker
Description I (and I assume probably others as well) need the Planetiler build for an area of my interest, but want to avoid installing Java locally. An ready-to-go, dockerized setup would save much time from my workflow (I 've had problems setting up multiple Java versions in the past)
We should follow the same build as Planetiler itself: https://github.com/onthegomap/planetiler/discussions/714 which will reduce the potential drift between here and upstream. Any reason that wouldn't work?
(Sorry for the late reply)
Your suggestion is admittedly solid. I 'd love to take it on, but I am not familiar with the Java ecosystem. For my case I went on to manually write a simple Dockerfile, and a shell/powershell script to automate the tile generation process. If you 'd like to incorporate it this way I 'd be happy to open a PR. This is my fork.
Thanks for your time and effort!
# DOCKERFILE
FROM maven:3-eclipse-temurin-21-alpine
WORKDIR /basemaps
COPY . /basemaps
WORKDIR /basemaps/tiles
RUN mvn clean package
# Powershell Script
# Set the name of the area
$AREA_NAME="my_beloved_home_country"
# Run a Docker container and mount the output directory,
# then download the source data and build the planetiler profile.
# The .pmtiles archive will be saved in the basemaps/output directory.
docker run -v ${pwd}/output:/basemaps/output -it basemaps bash -c "\
java -jar /basemaps/tiles/target/*-with-deps.jar --download --force --area=$AREA_NAME && \
mv /basemaps/tiles/$AREA_NAME.pmtiles /basemaps/output/$AREA_NAME.pmtiles "
# Move the generated pmtiles file to the basemaps/tiles directory
mv "./output/$AREA_NAME.pmtiles" "./tiles/$AREA_NAME.pmtiles"
# Remove the output directory
rm ./output
COPY . /basemaps
By default the source downloads, possibly gigabytes of NE, OSM water/land polygons, and OSM files are stored in data/
in the tiles
dir of this repo checkout, and gitignored, won't this Dockerfile line copy the entire data contents into the image? Is there a way to mount that as an input volume* instead?
I think this is a simpler approach:
https://github.com/protomaps/basemaps/pull/269
The README will mount the data
dir, which lets you re-use the downloads across runs and move the output to the host machine. It also sends only the minimal build context when building the image.
I'm going to close this as done - reopen if there's issues running in Docker.