enzet / map-machine

Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible
MIT License
504 stars 31 forks source link

add support for Docker #108

Closed Strubbl closed 2 years ago

Strubbl commented 2 years ago

This pull requests adds support to let map-machine run in a container. The added Dockerfile is a first running version, which has room for improvement, e.g. do not run the processes as root and use a virtual env, reduce image size by cleaning up apt cache. The .dockerignore ignores copying files to the container, which are not needed.

The docker build and an example call can look like this:

docker build -t strubbl_mapmachine .
docker run -v /data/mapmachine/maps:/maps strubbl_mapmachine render --cache /maps/cache -z 18 -o /maps/wentorf.svg -b 10.2445866411,53.4858307519,10.2726961915,53.4981753961

What is GEOS library used for? My example render call works without this library being installed. Do you know which Debian package is needed to be installed, e.g. libgeos-dev?

enzet commented 2 years ago

Hello @Strubbl!

Thank you for your request! To be honest, I'm not that familiar with Docker but it surely seems like a good idea.

The GEOS library is used by Shapely, which in turn is used for parallel shift. So if your OSM data don't have such tags as placement=* or man_made=embankment it won't be used. To be precise, Shapely requires GEOS >=3.3. I use libgeos-dev Debian package in Ubuntu and geos Brew formula in macOS.

Something strange has happened with Black since you have no changes in those files. Could it have something to do with Docker or is it an issue on my side?

Thank you for participating! I'm gonna celebrate the first pull request! 🥳

enzet commented 2 years ago

Well indeed the problem was on my side. I didn't specify the version of Black and it has just been updated.

Could you please update your branch?

enzet commented 2 years ago

And one more little detail. Could you please use the following format for commit messages: starting with a capital letter and ending with a dot. It's a bit odd, but it was deliberately used since the very beginning, so it would be nice to keep Git history consistent.

I'll add this recommendation to the CONTRIBUTING.md.

Strubbl commented 2 years ago

ok, I rebased to the latest main commit as of now and reformatted the commit message, but i needed to force push to keep the commit history clean. I also added libgeos-dev to the list of installed packages

Strubbl commented 2 years ago

is it anyhow possible to see a rendered version of the doc contributing.moi? I could not find it. Or do i have to translate that anyhow?

edit: i just found it in the .github/ folder. Maybe it is worth to add a reference to that file from the readme?

enzet commented 2 years ago

ok, I rebased to the latest main commit as of now and reformatted the commit message, but i needed to force push to keep the commit history clean. I also added libgeos-dev to the list of installed packages

Great! Thank you!

Maybe it is worth to add a reference to that file from the readme?

That would be nice!

I'm afraid there is still no simple way to deal with Moire files. My fault. If you want, you can just edit Markdown files, I'll make everything consistent later.

enzet commented 2 years ago

Should I merge this request now or you want to update readme in this patch?

Strubbl commented 2 years ago

You can merge this. I do not have an idea now, how i would update the readme

enzet commented 2 years ago

I do not have an idea now, how i would update the readme

Fill free to just edit README.md. Ignore .moi files.