From 3f52cf2022a341657ffb430abe815fe10ef724ff Mon Sep 17 00:00:00 2001 From: Sven Fischer Date: Mon, 31 Jan 2022 20:33:18 +0100 Subject: [PATCH] Add support for Docker. 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 ``` --- .dockerignore | 4 ++++ Dockerfile | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f681fbd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +Dockerfile +.git/ +tests/ + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1223eaa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.9-slim-bullseye + +WORKDIR /app + +COPY . /app/ + +RUN \ + apt update && \ + apt install -y --no-install-recommends gcc libcairo2-dev libgeos-dev && \ + pip install --upgrade pip && \ + pip install . && \ + mkdir -p /maps/cache + +VOLUME ["/maps"] +ENTRYPOINT ["map-machine"] +