Compare commits

..

9 Commits

Author SHA1 Message Date
Alexander Overvoorde
64c66a7d0b Make setup for automatic updates optional through UPDATES variable 2019-11-07 21:12:29 +01:00
Alexander Overvoorde
626158f677 Fix remaining references to PostgreSQL 10 2019-10-22 23:11:50 +02:00
Alexander Overvoorde
ca1626a9fc Merge branch 'Y0ngg4n-postgresql-12-upgrade' 2019-10-20 21:49:03 +02:00
Yonggan
101bb62e45 Fix README.md 2019-10-16 18:18:22 +02:00
root
e249f30d40 Upgrade to postgresql 12 2019-10-14 23:40:49 +02:00
Alexander Overvoorde
6e5f4f485d Add proper handling of docker stop 2019-10-12 12:35:16 +02:00
Alexander Overvoorde
ca4b1acb04 Add planet-import-complete file during imports 2019-10-12 12:21:10 +02:00
Alexander Overvoorde
40ebaf7934 Merge pull request #73 from stevo01/master
use tag v4.23.0 from openstreetmap-carto instead to use master
2019-10-04 19:48:38 +02:00
Steffen Volkmann
bfcc7d7c44 use tag v4.23.0 from openstreetmap-carto instead to use master 2019-10-03 18:15:41 +02:00
4 changed files with 66 additions and 40 deletions

View File

@@ -10,7 +10,10 @@ ENV UPDATES=disabled
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install dependencies
RUN echo "deb [ allow-insecure=yes ] http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main" >> /etc/apt/sources.list.d/pgdg.list \
RUN apt-get update \
&& apt-get install wget gnupg2 lsb-core -y \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb [ trusted=yes ] http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y apt-transport-https ca-certificates \
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
@@ -24,7 +27,9 @@ RUN echo "deb [ allow-insecure=yes ] http://apt.postgresql.org/pub/repos/apt/ bi
fonts-noto-hinted \
fonts-noto-unhinted \
clang \
gcc \
gdal-bin \
make \
git-core \
libagg-dev \
libboost-all-dev \
@@ -52,10 +57,9 @@ RUN echo "deb [ allow-insecure=yes ] http://apt.postgresql.org/pub/repos/apt/ bi
nodejs \
npm \
postgis \
postgresql-10 \
postgresql-10-postgis-2.5 \
postgresql-10-postgis-2.5-scripts \
postgresql-contrib-10 \
postgresql-12 \
postgresql-server-dev-12 \
postgresql-contrib-12 \
protobuf-c-compiler \
python-mapnik \
sudo \
@@ -72,6 +76,11 @@ RUN echo "deb [ allow-insecure=yes ] http://apt.postgresql.org/pub/repos/apt/ bi
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
# Set up PostGIS
RUN wget http://download.osgeo.org/postgis/source/postgis-3.0.0rc2.tar.gz
RUN tar -xvzf postgis-3.0.0rc2.tar.gz
RUN cd postgis-3.0.0rc2 && ./configure && make && make install
# Set up renderer user
RUN adduser --disabled-password --gecos "" renderer
USER renderer
@@ -109,7 +118,8 @@ USER renderer
# Configure stylesheet
WORKDIR /home/renderer/src
RUN git clone https://github.com/gravitystorm/openstreetmap-carto.git
RUN git clone https://github.com/gravitystorm/openstreetmap-carto.git \
&& git -C openstreetmap-carto checkout v4.23.0
WORKDIR /home/renderer/src/openstreetmap-carto
USER root
RUN npm install -g carto@0.18.2
@@ -141,12 +151,12 @@ RUN ln -sf /dev/stdout /var/log/apache2/access.log \
&& ln -sf /dev/stderr /var/log/apache2/error.log
# Configure PosgtreSQL
COPY postgresql.custom.conf.tmpl /etc/postgresql/10/main/
COPY postgresql.custom.conf.tmpl /etc/postgresql/12/main/
RUN chown -R postgres:postgres /var/lib/postgresql \
&& chown postgres:postgres /etc/postgresql/10/main/postgresql.custom.conf.tmpl \
&& echo "\ninclude 'postgresql.custom.conf'" >> /etc/postgresql/10/main/postgresql.conf
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/10/main/pg_hba.conf \
&& echo "host all all ::/0 md5" >> /etc/postgresql/10/main/pg_hba.conf
&& chown postgres:postgres /etc/postgresql/12/main/postgresql.custom.conf.tmpl \
&& echo "\ninclude 'postgresql.custom.conf'" >> /etc/postgresql/12/main/postgresql.conf
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/12/main/pg_hba.conf \
&& echo "host all all ::/0 md5" >> /etc/postgresql/12/main/pg_hba.conf
# copy update scripts
COPY openstreetmap-tiles-update-expire /usr/bin/

View File

@@ -8,5 +8,5 @@ push: build
test: build
docker volume create openstreetmap-data
docker run -v openstreetmap-data:/var/lib/postgresql/10/main overv/openstreetmap-tile-server import
docker run -v openstreetmap-data:/var/lib/postgresql/10/main -p 80:80 -d overv/openstreetmap-tile-server run
docker run -v openstreetmap-data:/var/lib/postgresql/12/main overv/openstreetmap-tile-server import
docker run -v openstreetmap-data:/var/lib/postgresql/12/main -p 80:80 -d overv/openstreetmap-tile-server run

View File

@@ -13,7 +13,7 @@ Next, download an .osm.pbf extract from geofabrik.de for the region that you're
```
docker run \
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
overv/openstreetmap-tile-server \
import
```
@@ -22,18 +22,19 @@ If the container exits without errors, then your data has been successfully impo
### Automatic updates (optional)
If your import is an extract of the planet and has polygonal bounds associated with it, like those from geofabrik.de, then it is possible to set your server up for automatic updates. Make sure to reference both the OSM file and the polygon file during the import process to facilitate this:
If your import is an extract of the planet and has polygonal bounds associated with it, like those from geofabrik.de, then it is possible to set your server up for automatic updates. Make sure to reference both the OSM file and the polygon file during the import process to facilitate this, and also include the `UPDATES=enabled` variable:
```
docker run \
-e UPDATES=enabled \
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
-v /absolute/path/to/luxembourg.poly:/data.poly \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
overv/openstreetmap-tile-server \
import
```
Refer to the section *Automatic updating and tile expiry* to actually enable the updates.
Refer to the section *Automatic updating and tile expiry* to actually enable the updates while running the tile server.
## Running the server
@@ -42,7 +43,7 @@ Run the server like this:
```
docker run \
-p 80:80 \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-d overv/openstreetmap-tile-server \
run
```
@@ -57,21 +58,23 @@ Tiles that have already been rendered will be stored in `/var/lib/mod_tile`. To
docker volume create openstreetmap-rendered-tiles
docker run \
-p 80:80 \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-v openstreetmap-rendered-tiles:/var/lib/mod_tile \
-d overv/openstreetmap-tile-server \
run
```
**If you do this, then make sure to also run the import with the `openstreetmap-rendered-tiles` volume to make sure that caching works properly across updates!**
### Enabling automatic updating (optional)
Given that you've specified both the OSM data and polygon as specified in the *Automatic updates* section during server setup, you can enable the updating process by setting the variable `UPDATES` to `enabled`:
Given that you've set up your import as described in the *Automatic updates* section during server setup, you can enable the updating process by setting the `UPDATES` variable while running your server as well:
```
docker run \
-p 80:80 \
-e UPDATES=enabled \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-v openstreetmap-rendered-tiles:/var/lib/mod_tile \
-d overv/openstreetmap-tile-server \
run
@@ -86,7 +89,7 @@ To enable the `Access-Control-Allow-Origin` header to be able to retrieve tiles
```
docker run \
-p 80:80 \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-e ALLOW_CORS=1 \
-d overv/openstreetmap-tile-server \
run
@@ -100,7 +103,7 @@ To connect to the PostgreSQL database inside the container, make sure to expose
docker run \
-p 80:80 \
-p 5432:5432 \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-d overv/openstreetmap-tile-server \
run
```
@@ -118,7 +121,7 @@ docker run \
-p 80:80 \
-p 5432:5432 \
-e PGPASSWORD=secret \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-d overv/openstreetmap-tile-server \
run
```
@@ -134,7 +137,7 @@ The import and tile serving processes use 4 threads by default, but this number
docker run \
-p 80:80 \
-e THREADS=24 \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-d overv/openstreetmap-tile-server \
run
```
@@ -146,7 +149,7 @@ The import and tile serving processes use 800 MB RAM cache by default, but this
docker run \
-p 80:80 \
-e "OSM2PGSQL_EXTRA_ARGS=-C 4096" \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-d overv/openstreetmap-tile-server \
run
```
@@ -158,7 +161,7 @@ The database use the autovacuum feature by default. This behavior can be changed
docker run \
-p 80:80 \
-e AUTOVACUUM=off \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-d overv/openstreetmap-tile-server \
run
```
@@ -171,7 +174,7 @@ If you are planning to import the entire planet or you are running into memory e
docker run \
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
-v openstreetmap-nodes:/nodes \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-e "OSM2PGSQL_EXTRA_ARGS=--flat-nodes /nodes/flat_nodes.bin" \
overv/openstreetmap-tile-server \
import
@@ -196,7 +199,7 @@ To raise it use `--shm-size` parameter. For example:
```
docker run \
-p 80:80 \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-v openstreetmap-data:/var/lib/postgresql/12/main \
--shm-size="192m" \
-d overv/openstreetmap-tile-server \
run

23
run.sh
View File

@@ -3,9 +3,9 @@
set -x
function createPostgresConfig() {
cp /etc/postgresql/10/main/postgresql.custom.conf.tmpl /etc/postgresql/10/main/postgresql.custom.conf
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/10/main/postgresql.custom.conf
cat /etc/postgresql/10/main/postgresql.custom.conf
cp /etc/postgresql/12/main/postgresql.custom.conf.tmpl /etc/postgresql/12/main/postgresql.custom.conf
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/12/main/postgresql.custom.conf
cat /etc/postgresql/12/main/postgresql.custom.conf
}
function setPostgresPassword() {
@@ -42,6 +42,7 @@ if [ "$1" = "import" ]; then
wget -nv http://download.geofabrik.de/europe/luxembourg.poly -O /data.poly
fi
if [ "$UPDATES" = "enabled" ]; then
# determine and set osmosis_replication_timestamp (for consecutive updates)
osmium fileinfo /data.osm.pbf > /var/lib/mod_tile/data.osm.pbf.info
osmium fileinfo /data.osm.pbf | grep 'osmosis_replication_timestamp=' | cut -b35-44 > /var/lib/mod_tile/replication_timestamp.txt
@@ -49,6 +50,7 @@ if [ "$1" = "import" ]; then
# initial setup of osmosis workspace (for consecutive updates)
sudo -u renderer openstreetmap-tiles-update-expire $REPLICATION_TIMESTAMP
fi
# copy polygon file if available
if [ -f /data.poly ]; then
@@ -61,6 +63,9 @@ if [ "$1" = "import" ]; then
# Create indexes
sudo -u postgres psql -d gis -f indexes.sql
# Register that data has changed for mod_tile caching purposes
touch /var/lib/mod_tile/planet-import-complete
service postgresql stop
exit 0
@@ -92,8 +97,16 @@ if [ "$1" = "run" ]; then
/etc/init.d/cron start
fi
# Run
sudo -u renderer renderd -f -c /usr/local/etc/renderd.conf
# Run while handling docker stop's SIGTERM
stop_handler() {
kill -TERM "$child"
}
trap stop_handler SIGTERM
sudo -u renderer renderd -f -c /usr/local/etc/renderd.conf &
child=$!
wait "$child"
service postgresql stop
exit 0