From d578eca65c8ac80d931e28d6c269761e0b78da4d Mon Sep 17 00:00:00 2001 From: Harold Ship Date: Wed, 6 Jan 2016 14:28:19 +0200 Subject: [PATCH 1/8] Make this work --- Dockerfile | 1 + help.txt | 4 ++-- run.sh | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index c357792..9af456c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,6 +33,7 @@ RUN apt-get install -y postgresql-9.3-postgis-2.1 postgresql-contrib postgresql- # Install osm2pgsql RUN cd /tmp && git clone git://github.com/openstreetmap/osm2pgsql.git RUN cd /tmp/osm2pgsql && \ + git checkout 24e4d4bf273aaf3572fda11d2c0b32aa3156f84a && \ ./autogen.sh && \ ./configure && \ make && make install diff --git a/help.txt b/help.txt index c3cba5a..51b4eac 100644 --- a/help.txt +++ b/help.txt @@ -21,10 +21,10 @@ Set up a database saved on an external volume: volume that can be used to persist the data: docker run -v /data/osm-postgresql:/var/lib/postgresql homme/openstreetmap-tiles \ - initdb startdb createuser createdb migrate + initdb startdb createuser createdb Import data: - The following will import the .osm file at `/tmp/import.osm` into the + The following will import the .pbf file at `/tmp/import.pbf` into the database. docker run -v /data/osm-postgresql:/var/lib/postgresql -v /tmp:/data homme/openstreetmap-tiles \ diff --git a/run.sh b/run.sh index 0bb7e04..7485afb 100755 --- a/run.sh +++ b/run.sh @@ -56,8 +56,8 @@ createdb () { # Set the correct table ownership $asweb psql -d $dbname -c 'ALTER TABLE geometry_columns OWNER TO "www-data"; ALTER TABLE spatial_ref_sys OWNER TO "www-data";' - # Add the 900913 Spatial Reference System - $asweb psql -d $dbname -f /usr/local/share/osm2pgsql/900913.sql + # Add the Spatial Reference System + $asweb psql -d $dbname -f /usr/share/postgresql/9.3/contrib/postgis-2.1/spatial_ref_sys.sql } import () { From c2ef6e40f752957ea035272b880d353019ea00d4 Mon Sep 17 00:00:00 2001 From: Harold Ship Date: Wed, 6 Jan 2016 16:26:44 +0200 Subject: [PATCH 2/8] Update to newest docker-image and OSM Bright --- Dockerfile | 66 +++++++++++++++++++++++++++++++++------- configure.py.sed | 2 ++ osm-bright.osm2pgsql.sed | 5 +++ renderd.conf.sed | 3 +- 4 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 configure.py.sed create mode 100644 osm-bright.osm2pgsql.sed diff --git a/Dockerfile b/Dockerfile index 9af456c..7acc1fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,17 @@ -## -*- docker-image-name: "homme/openstreetmap-tiles:latest" -*- +## -*- docker-image-name: "haroldship/openstreetmap-tiles:latest" -*- ## # The OpenStreetMap Tile Server # # This creates an image with containing the OpenStreetMap tile server stack as # described at -# . +# . +# +# Based on homme/openstreetmap-tiles Homme Zwaagstra # -FROM phusion/baseimage:0.9.11 -MAINTAINER Homme Zwaagstra +FROM phusion/baseimage:0.9.18 +MAINTAINER Harold Ship # Set the locale. This affects the encoding of the Postgresql template # databases. @@ -61,17 +63,59 @@ RUN cd /tmp/mod_tile && \ ldconfig # Install the Mapnik stylesheet -RUN cd /usr/local/src && svn co http://svn.openstreetmap.org/applications/rendering/mapnik mapnik-style +#RUN cd /usr/local/src && svn co http://svn.openstreetmap.org/applications/rendering/mapnik mapnik-style # Install the coastline data -RUN cd /usr/local/src/mapnik-style && ./get-coastlines.sh /usr/local/share +#RUN cd /usr/local/src/mapnik-style && ./get-coastlines.sh /usr/local/share # Configure mapnik style-sheets -RUN cd /usr/local/src/mapnik-style/inc && cp fontset-settings.xml.inc.template fontset-settings.xml.inc -ADD datasource-settings.sed /tmp/ -RUN cd /usr/local/src/mapnik-style/inc && sed --file /tmp/datasource-settings.sed datasource-settings.xml.inc.template > datasource-settings.xml.inc -ADD settings.sed /tmp/ -RUN cd /usr/local/src/mapnik-style/inc && sed --file /tmp/settings.sed settings.xml.inc.template > settings.xml.inc +#RUN cd /usr/local/src/mapnik-style/inc && cp fontset-settings.xml.inc.template fontset-settings.xml.inc +#ADD datasource-settings.sed /tmp/ +#RUN cd /usr/local/src/mapnik-style/inc && sed --file /tmp/datasource-settings.sed datasource-settings.xml.inc.template > datasource-settings.xml.inc +#ADD settings.sed /tmp/ +#RUN cd /usr/local/src/mapnik-style/inc && sed --file /tmp/settings.sed settings.xml.inc.template > settings.xml.inc + +# Install node-carto to compile CartoCSS +RUN apt-get install -y node-carto + +# Download OSM Bright sources and polygons +RUN mkdir -p /usr/local/share/maps/style && \ + chmod a+rx /usr/local/share/maps/style && \ + cd /usr/local/share/maps/style && \ + wget https://github.com/mapbox/osm-bright/archive/master.zip && \ + wget http://data.openstreetmapdata.com/simplified-land-polygons-complete-3857.zip && \ + wget http://data.openstreetmapdata.com/land-polygons-split-3857.zip && \ + wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places_simple.zip + +# Unpack the OSM Bright sources and polygons +RUN cd /usr/local/share/maps/style && \ + unzip '*.zip' && \ + mkdir osm-bright-master/shp && \ + mv land-polygons-split-3857 osm-bright-master/shp && \ + mv simplified-land-polygons-complete-3857 osm-bright-master/shp && \ + mkdir ne_10m_populated_places_simple && \ + mv ne_10m_populated_places_simple.* ne_10m_populated_places_simple && \ + mv ne_10m_populated_places_simple osm-bright-master/shp/ + +# Create shapeindices for polygons +RUN cd /usr/local/share/maps/style/osm-bright-master/shp/land-polygons-split-3857 && shapeindex land_polygons.shp +RUN cd /usr/local/share/maps/style/osm-bright-master/shp/simplified-land-polygons-complete-3857 && shapeindex simplified_land_polygons.shp + +# Configure OSM Bright style sheet +ADD osm-bright.osm2pgsql.sed /tmp/ +RUN cd /usr/local/share/maps/style/osm-bright-master/osm-bright && \ + sed --file /tmp/osm-bright.osm2pgsql.sed --in-place osm-bright.osm2pgsql.mml +ADD configure.py.sed /tmp/ +RUN cd /usr/local/share/maps/style/osm-bright-master && \ + sed --file /tmp/configure.py.sed configure.py.sample > configure.py + +# Build the OSM Bright style sheet in cartocss +RUN cd /usr/local/share/maps/style/osm-bright-master && \ + ./make.py + +# Build the OSM Bright style sheet in mapnik format +RUN cd /usr/local/share/maps/style/OSMBright && \ + carto project.mml > OSMBright.xml # Configure renderd ADD renderd.conf.sed /tmp/ diff --git a/configure.py.sed b/configure.py.sed new file mode 100644 index 0000000..8a932a4 --- /dev/null +++ b/configure.py.sed @@ -0,0 +1,2 @@ +s|config\["postgis"\]\["dbname"\] = "osm"|config["postgis"]["dbname"] = "gis"| +s|path.expanduser("~/Documents/MapBox/project")|path.expanduser("/usr/local/share/maps/style")| diff --git a/osm-bright.osm2pgsql.sed b/osm-bright.osm2pgsql.sed new file mode 100644 index 0000000..1ccd05d --- /dev/null +++ b/osm-bright.osm2pgsql.sed @@ -0,0 +1,5 @@ +s|http://data.openstreetmapdata.com/\(.*\).zip|/usr/local/share/maps/style/osm-bright-master/shp/\1/\1.shp| +s|http://mapbox-geodata.s3.amazonaws.com/natural-earth-1.4.0/cultural/\(.*\).zip|/usr/local/share/maps/style/osm-bright-master/shp/ne_10m_populated_places_simple/ne_10m_populated_places_simple.shp| +/"file"/i\ + "type": "shape", +s|"srs": "",|"srs": "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",| diff --git a/renderd.conf.sed b/renderd.conf.sed index 1bf57ab..534d925 100644 --- a/renderd.conf.sed +++ b/renderd.conf.sed @@ -1,6 +1,5 @@ # Perform sed substitutions for `renderd.conf` s/;socketname=/socketname=/ s/plugins_dir=\/usr\/lib\/mapnik\/input/plugins_dir=\/usr\/local\/lib\/mapnik\/input/ -s/\(font_dir=\/usr\/share\/fonts\/truetype\)/\1\/ttf-dejavu/ -s/XML=.*/XML=\/usr\/local\/src\/mapnik-style\/osm.xml/ +s/XML=.*/XML=\/usr\/local\/share\/maps\/style\/OSMBright\/OSMBright.xml/ s/HOST=tile.openstreetmap.org/HOST=localhost/ From c1b6e3be892c711b165feeda5ef1bba40f183ba7 Mon Sep 17 00:00:00 2001 From: Harold Ship Date: Sun, 10 Jan 2016 12:37:18 +0200 Subject: [PATCH 3/8] added GETTING_STARTED.md, updated README.md, and fixed help.txt --- GETTING_STARTED.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ README.md | 11 +++++++---- help.txt | 6 +++--- 3 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 GETTING_STARTED.md diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md new file mode 100644 index 0000000..d1808d1 --- /dev/null +++ b/GETTING_STARTED.md @@ -0,0 +1,45 @@ + +These instructions are for **linux only**, and assume that Docker is up and running. + +1. Make a working directory. + + mkdir osm + cd osm + +2. Make a directory to contain the import file. + + mkdir import + cd import + +3. Download the import file. *You can use any OSM PBF file, but it is important to name it* `import.pbf`. + + curl -o import.pbf http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf + +4. Move back to working directory. + + cd .. + +5. Run the image, with help. + + docker run -it haroldship/openstreetmap-tiles-docker help + +6. If everything goes well, then there are 3 steps: + + * Initial setup, which includes creating the database and user + * Importing + * Running + +7. Initialize: *It is important to get the path to the PostgreSQL data directory correct.* + + mkdir data + docker run -v $PWD/data:/var/lib/postgresql -it haroldship/openstreetmap-tiles-docker initdb startdb createuser createdb + +8. Import: *It is important to get the path to the import directory correct.* + + docker run -v $PWD/import:/data -v $PWD/data:/var/lib/postgresql \ + -it haroldship/openstreetmap-tiles-docker startdb import + +9. Start the services. + + docker run -v $PWD/data:/var/lib/postgresql \ + -b haroldship/openstreetmap-tiles-docker startdb startservices \ No newline at end of file diff --git a/README.md b/README.md index 24591e7..3fbcd0f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ This repository contains instructions for building a [Docker](https://www.docker.io/) image containing the OpenStreetMap tile serving software stack. It is based on the -[Switch2OSM instructions](http://switch2osm.org/serving-tiles/manually-building-a-tile-server-12-04/). +[Switch2OSM instructions](http://switch2osm.org/serving-tiles/manually-building-a-tile-server-14-04/). + +The tiles are styled using [OSM Bright](https://github.com/mapbox/osm-bright/). As well as providing an easy way to set up and run the tile serving software it also provides instructions for managing the back end database, allowing you to: @@ -12,7 +14,7 @@ also provides instructions for managing the back end database, allowing you to: * Import OSM data into the database * Drop the database -Run `docker run homme/openstreetmap-tiles` for usage instructions. +Run `docker run haroldship/openstreetmap-tiles-docker` for usage instructions. ## About @@ -22,11 +24,12 @@ includes: * Postgresql 9.3 * Apache 2.2 -* The latest [Osm2pgsql](http://wiki.openstreetmap.org/wiki/Osm2pgsql) code (at - the time of image creation) +* [Osm2pgsql](http://wiki.openstreetmap.org/wiki/Osm2pgsql) from Oct 22 (24e4d4bf273aaf3572fda11d2c0b32aa3156f84a) * The latest [Mapnik](http://mapnik.org/) code (at the time of image creation) * The latest [Mod_Tile](http://wiki.openstreetmap.org/wiki/Mod_tile) code (at the time of image creation) +* The latest [OSM Bright](https://github.com/mapbox/osm-bright/) code (at the + the time of image creation) ## Issues diff --git a/help.txt b/help.txt index 51b4eac..aeeaf41 100644 --- a/help.txt +++ b/help.txt @@ -20,20 +20,20 @@ Set up a database saved on an external volume: The following command will initialise the postgresql database on an external volume that can be used to persist the data: - docker run -v /data/osm-postgresql:/var/lib/postgresql homme/openstreetmap-tiles \ + docker run -v /data/osm-postgresql:/var/lib/postgresql haroldship/openstreetmap-tiles-docker \ initdb startdb createuser createdb Import data: The following will import the .pbf file at `/tmp/import.pbf` into the database. - docker run -v /data/osm-postgresql:/var/lib/postgresql -v /tmp:/data homme/openstreetmap-tiles \ + docker run -v /data/osm-postgresql:/var/lib/postgresql -v /tmp:/data haroldship/openstreetmap-tiles-docker \ startdb import Start the webserver: Once data is loaded and users have been created run the webserver: - docker run -P -v /data/osm-postgresql:/var/lib/postgresql homme/openstreetmap-tiles \ + docker run -P -v /data/osm-postgresql:/var/lib/postgresql haroldship/openstreetmap-tiles-docker \ startdb startservices For further information run the cli and look at /usr/local/share/doc/README.md. From 114058d46aa50a948998c5fa5ba821bdbbf60d6d Mon Sep 17 00:00:00 2001 From: Harold Ship Date: Sun, 10 Jan 2016 14:04:04 +0200 Subject: [PATCH 4/8] fix GETTING_STARTED.md --- GETTING_STARTED.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index d1808d1..5a02336 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -29,12 +29,16 @@ These instructions are for **linux only**, and assume that Docker is up and runn * Importing * Running -7. Initialize: *It is important to get the path to the PostgreSQL data directory correct.* +7. Initialize: +*It is important to get the path to the PostgreSQL data directory correct.* mkdir data - docker run -v $PWD/data:/var/lib/postgresql -it haroldship/openstreetmap-tiles-docker initdb startdb createuser createdb + docker run -v $PWD/data:/var/lib/postgresql -it haroldship/openstreetmap-tiles-docker \ + initdb startdb createuser createdb -8. Import: *It is important to get the path to the import directory correct.* +8. Import: +*It is important to get the path to the import directory correct.* +*This step can take a long time, depending on how large a database you are importing.* docker run -v $PWD/import:/data -v $PWD/data:/var/lib/postgresql \ -it haroldship/openstreetmap-tiles-docker startdb import From c41ca90cf46d1ac465fc9b8f5c86b428edf9983c Mon Sep 17 00:00:00 2001 From: Harold Ship Date: Sun, 10 Jan 2016 14:11:53 +0200 Subject: [PATCH 5/8] fix GETTING_STARTED.md more --- GETTING_STARTED.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 5a02336..fddeede 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -33,7 +33,8 @@ These instructions are for **linux only**, and assume that Docker is up and runn *It is important to get the path to the PostgreSQL data directory correct.* mkdir data - docker run -v $PWD/data:/var/lib/postgresql -it haroldship/openstreetmap-tiles-docker \ + docker run -v $PWD/data:/var/lib/postgresql \ + -it haroldship/openstreetmap-tiles-docker \ initdb startdb createuser createdb 8. Import: @@ -46,4 +47,4 @@ These instructions are for **linux only**, and assume that Docker is up and runn 9. Start the services. docker run -v $PWD/data:/var/lib/postgresql \ - -b haroldship/openstreetmap-tiles-docker startdb startservices \ No newline at end of file + -d -P haroldship/openstreetmap-tiles-docker startdb startservices \ No newline at end of file From 2f9d8b4219f18bb3bb3d32c7b008d2a2a3ac90f2 Mon Sep 17 00:00:00 2001 From: Harold Ship Date: Sun, 10 Jan 2016 14:46:27 +0200 Subject: [PATCH 6/8] fix issues link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3fbcd0f..6635c0c 100644 --- a/README.md +++ b/README.md @@ -35,5 +35,5 @@ includes: This is a work in progress and although generally adequate it could benefit from improvements. Please -[submit issues](https://github.com/geo-data/openstreetmap-tiles-docker/issues) +[submit issues](https://github.com/haroldship/openstreetmap-tiles-docker/issues) on GitHub. Pull requests are very welcome! From d16991225f2e82cef2aed513b8dee4c9e7dd0c56 Mon Sep 17 00:00:00 2001 From: Harold Ship Date: Wed, 27 Jan 2016 10:50:54 +0200 Subject: [PATCH 7/8] fix 'die' function in run.sh --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 7485afb..e5216f6 100755 --- a/run.sh +++ b/run.sh @@ -9,7 +9,7 @@ asweb="setuser www-data" die () { msg=$1 - echo "FATAL ERROR: " msg > 2 + echo "FATAL ERROR: "$msg >&2 exit } From 60ad0552350be8efb9dee1e93e2828f7b7c9a613 Mon Sep 17 00:00:00 2001 From: Harold Ship Date: Wed, 27 Jan 2016 11:05:48 +0200 Subject: [PATCH 8/8] fix run.sh die and add forceinitdb option --- run.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/run.sh b/run.sh index e5216f6..f1380ed 100755 --- a/run.sh +++ b/run.sh @@ -9,7 +9,7 @@ asweb="setuser www-data" die () { msg=$1 - echo "FATAL ERROR: "$msg >&2 + echo "FATAL ERROR: $msg" >&2 exit } @@ -27,7 +27,19 @@ initdb () { then die "Initialisation failed: the directory is not empty: /var/lib/postgresql/9.3/main" fi + _initdb +} + +forceinitdb() { + echo "Initialising postgresql by FORCE" + if [ -d /var/lib/postgresql/9.3/main ] && [ $( ls -A /var/lib/postgresql/9.3/main | wc -c ) -ge 0 ] + then + rm -rf /var/lib/postgresql/9.3/main/* + fi + _initdb +} +_initdb() { mkdir -p /var/lib/postgresql/9.3/main && chown -R postgres /var/lib/postgresql/ sudo -u postgres -i /usr/lib/postgresql/9.3/bin/initdb --pgdata /var/lib/postgresql/9.3/main ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /var/lib/postgresql/9.3/main/server.crt