From d0334ba6f87aef91e5d72ecddb464ecea8089135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20G=C3=BCntner?= Date: Sun, 16 Nov 2014 21:26:37 +0100 Subject: [PATCH] Initial commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Güntner --- Dockerfile | 39 +++++++++++++++++++++++++++++++++++++++ README.md | 32 ++++++++++++++++++++++++++++++++ apache2/000-default.conf | 40 ++++++++++++++++++++++++++++++++++++++++ apache2/run | 3 +++ renderd/run | 12 ++++++++++++ runit_bootstrap | 6 ++++++ tile.load | 1 + 7 files changed, 133 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 apache2/000-default.conf create mode 100644 apache2/run create mode 100644 renderd/run create mode 100755 runit_bootstrap create mode 100644 tile.load diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c0bde5a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +# DOCKER-VERSION 1.3.1 +# VERSION 0.1 +FROM debian:jessie +MAINTAINER Maximilian Güntner + +ENV DEBIAN_FRONTEND noninteractive + +ENV OSM_CARTO_VERSION 2.24.0 +ENV MOD_TILE_VERSION master +ENV PARALLEL_BUILD 4 + +RUN touch /etc/inittab +RUN apt-get update && apt-get install -y -q autoconf libtool libmapnik-dev apache2-dev curl unzip gdal-bin mapnik-utils node-carto apache2 wget runit sudo + +RUN cd /tmp && wget https://github.com/gravitystorm/openstreetmap-carto/archive/v$OSM_CARTO_VERSION.tar.gz && tar -xzf v$OSM_CARTO_VERSION.tar.gz +RUN mkdir /usr/share/mapnik && mv /tmp/openstreetmap-carto-$OSM_CARTO_VERSION /usr/share/mapnik/ +RUN cd /usr/share/mapnik/openstreetmap-carto-$OSM_CARTO_VERSION/ && ./get-shapefiles.sh && cp project.mml project.mml.orig + +RUN cd /tmp && wget https://github.com/openstreetmap/mod_tile/archive/$MOD_TILE_VERSION.tar.gz && tar -xzf $MOD_TILE_VERSION.tar.gz +RUN cd /tmp/mod_tile-$MOD_TILE_VERSION/ && ./autogen.sh && ./configure && make -j $PARALLEL_BUILD && make install && make install-mod_tile + +RUN mkdir -p /var/lib/mod_tile && chown www-data:www-data /var/lib/mod_tile +RUN mkdir -p /var/run/renderd && chown www-data:www-data /var/run/renderd + +RUN mkdir -p /etc/service/renderd && mkdir -p /etc/service/apache2 +COPY ./apache2/run /etc/service/apache2/run +COPY ./renderd/run /etc/service/renderd/run +RUN chown root:root /etc/service/renderd/run /etc/service/apache2/run +RUN chmod u+x /etc/service/renderd/run /etc/service/apache2/run + +COPY ./tile.load /etc/apache2/mods-available/tile.load +COPY ./apache2/000-default.conf /etc/apache2/sites-enabled/000-default.conf +RUN ln -s /etc/apache2/mods-available/tile.load /etc/apache2/mods-enabled/ + +COPY runit_bootstrap /usr/sbin/runit_bootstrap +RUN chmod 755 /usr/sbin/runit_bootstrap + +EXPOSE 80 +ENTRYPOINT ["/usr/sbin/runit_bootstrap"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..8d43341 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# docker-renderd-osm + +A basic image for rendering/serving tiles using OpenStreetMap data from an external +PostgreSQL instance. + +## Build instructions + +Build using + + # docker build -t mguentner/renderd-osm github.com/mguentner/docker-renderd-osm.git + +## Running + +This container is designed to work together with +[openfirmware/docker-postgres-osm](https://registry.hub.docker.com/u/openfirmware/postgres-osm/). +This document assumes that OpenStreetMap data has already been imported. +If not build/pull [openfirmware/docker-osm2pgsql](https://registry.hub.docker.com/u/openfirmware/osm2pgsql/) and follow the instructions. + +First, start the already configured PostgreSQL container: + + # docker start postgres-osm + +Now, start the renderd container and link them together: + + # docker run -i -t -p 8080:80 --link postgres-osm:pg mguentner/renderd-osm:latest + +Once the container is up you should be able to see a small map of the +world once you point your browser to [http://127.0.0.1:8080/osm_tiles/0/0/0.png](http://127.0.0.1:8080/osm_tiles/0/0/0.png) + +## About + +This Dockerfile has been put together using the [Debian Tileserver Install Guide](https://wiki.debian.org/OSM/tileserver/jessie) diff --git a/apache2/000-default.conf b/apache2/000-default.conf new file mode 100644 index 0000000..0893f73 --- /dev/null +++ b/apache2/000-default.conf @@ -0,0 +1,40 @@ + + # The ServerName directive sets the request scheme, hostname and port that + # the server uses to identify itself. This is used when creating + # redirection URLs. In the context of virtual hosts, the ServerName + # specifies what hostname must appear in the request's Host: header to + # match this virtual host. For the default virtual host (this file) this + # value is not decisive as it is used as a last resort host regardless. + # However, you must set it for any further virtual host explicitly. + #ServerName www.example.com + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + #LogLevel info ssl:warn + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf + + LoadTileConfigFile /usr/local/etc/renderd.conf + ModTileRenderdSocketName /var/run/renderd/renderd.sock + # Timeout before giving up for a tile to be rendered + ModTileRequestTimeout 0 + # Timeout before giving up for a tile to be rendered that is otherwise missing + ModTileMissingRequestTimeout 30 + + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet + diff --git a/apache2/run b/apache2/run new file mode 100644 index 0000000..3558682 --- /dev/null +++ b/apache2/run @@ -0,0 +1,3 @@ +#!/bin/bash +source /etc/apache2/envvars +exec /usr/sbin/apache2ctl -DFOREGROUND diff --git a/renderd/run b/renderd/run new file mode 100644 index 0000000..ac1f98d --- /dev/null +++ b/renderd/run @@ -0,0 +1,12 @@ +#!/bin/bash +exec 2>&1 +source /etc/envvars +sed -i "s/^XML=.*/XML=\/usr\/share\/mapnik\/openstreetmap-carto-$OSM_CARTO_VERSION\/style.xml/" /usr/local/etc/renderd.conf +sed -i "s/^HOST=.*/HOST=localhost/" /usr/local/etc/renderd.conf +sed -i "s/^plugins_dir=.*/plugins_dir=\/usr\/lib\/mapnik\/2.2\/input\//" /usr/local/etc/renderd.conf + +cd /usr/share/mapnik/openstreetmap-carto-$OSM_CARTO_VERSION/ +cp project.mml.orig project.mml +sed -i "s/\"dbname\": \"gis\"/\"host\": \"$PG_PORT_5432_TCP_ADDR\",\n\"port\": \"$PG_PORT_5432_TCP_PORT\",\n\"user\": \"$PG_ENV_OSM_USER\",\n\"dbname\":\"$PG_ENV_OSM_DB\"/" project.mml +carto project.mml > style.xml +exec sudo -u www-data LD_LIBRARY_PATH=/usr/local/lib/ /usr/local/bin/renderd -f --config /usr/local/etc/renderd.conf diff --git a/runit_bootstrap b/runit_bootstrap new file mode 100755 index 0000000..00073bb --- /dev/null +++ b/runit_bootstrap @@ -0,0 +1,6 @@ +#!/bin/bash +# it is not possible to pass environment variables to runit +# so we just save them in a file which we can source from +# run scripts. +export > /etc/envvars +exec /usr/sbin/runsvdir-start diff --git a/tile.load b/tile.load new file mode 100644 index 0000000..eb6b330 --- /dev/null +++ b/tile.load @@ -0,0 +1 @@ +LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so