protomaps / basemaps

Basemap PMTiles generation and cartographic styles for OpenStreetMap data and more
https://maps.protomaps.com/
Other
348 stars 44 forks source link

Generate tiles with Docker #184

Closed lymperis-e closed 1 month ago

lymperis-e commented 10 months ago

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)

bdon commented 10 months ago

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?

lymperis-e commented 7 months ago

(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
bdon commented 7 months ago
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?

bdon commented 3 months ago

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.

bdon commented 1 month ago

I'm going to close this as done - reopen if there's issues running in Docker.