Compare commits

...

3 Commits

Author SHA1 Message Date
Alexander Overvoorde
789ff772be Change custom config to be overridable 2019-12-05 21:27:46 +01:00
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
3 changed files with 21 additions and 19 deletions

View File

@@ -10,8 +10,8 @@ ENV UPDATES=disabled
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install dependencies # Install dependencies
RUN apt-get update \ RUN apt-get update \
&& apt-get install wget gnupg2 lsb-core -y \ && apt-get install wget gnupg2 lsb-core -y \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ && 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 \ && 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 update \
@@ -151,12 +151,11 @@ RUN ln -sf /dev/stdout /var/log/apache2/access.log \
&& ln -sf /dev/stderr /var/log/apache2/error.log && ln -sf /dev/stderr /var/log/apache2/error.log
# Configure PosgtreSQL # 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 \ RUN chown -R postgres:postgres /var/lib/postgresql \
&& chown postgres:postgres /etc/postgresql/10/main/postgresql.custom.conf.tmpl \ && chown postgres:postgres /etc/postgresql/12/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/12/main/pg_hba.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/12/main/pg_hba.conf
&& echo "host all all ::/0 md5" >> /etc/postgresql/10/main/pg_hba.conf
# copy update scripts # copy update scripts
COPY openstreetmap-tiles-update-expire /usr/bin/ COPY openstreetmap-tiles-update-expire /usr/bin/

View File

@@ -22,10 +22,11 @@ If the container exits without errors, then your data has been successfully impo
### Automatic updates (optional) ### 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 \ docker run \
-e UPDATES=enabled \
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \ -v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
-v /absolute/path/to/luxembourg.poly:/data.poly \ -v /absolute/path/to/luxembourg.poly:/data.poly \
-v openstreetmap-data:/var/lib/postgresql/12/main \ -v openstreetmap-data:/var/lib/postgresql/12/main \
@@ -33,7 +34,7 @@ docker run \
import 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 ## Running the server
@@ -67,7 +68,7 @@ docker run \
### Enabling automatic updating (optional) ### 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 \ docker run \

20
run.sh
View File

@@ -3,9 +3,9 @@
set -x set -x
function createPostgresConfig() { function createPostgresConfig() {
cp /etc/postgresql/12/main/postgresql.custom.conf.tmpl /etc/postgresql/12/main/postgresql.custom.conf cp /etc/postgresql/12/main/postgresql.custom.conf.tmpl /etc/postgresql/12/main/conf.d/postgresql.custom.conf
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/12/main/postgresql.custom.conf sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/12/main/conf.d/postgresql.custom.conf
cat /etc/postgresql/12/main/postgresql.custom.conf cat /etc/postgresql/12/main/conf.d/postgresql.custom.conf
} }
function setPostgresPassword() { function setPostgresPassword() {
@@ -42,13 +42,15 @@ if [ "$1" = "import" ]; then
wget -nv http://download.geofabrik.de/europe/luxembourg.poly -O /data.poly wget -nv http://download.geofabrik.de/europe/luxembourg.poly -O /data.poly
fi fi
# determine and set osmosis_replication_timestamp (for consecutive updates) if [ "$UPDATES" = "enabled" ]; then
osmium fileinfo /data.osm.pbf > /var/lib/mod_tile/data.osm.pbf.info # determine and set osmosis_replication_timestamp (for consecutive updates)
osmium fileinfo /data.osm.pbf | grep 'osmosis_replication_timestamp=' | cut -b35-44 > /var/lib/mod_tile/replication_timestamp.txt osmium fileinfo /data.osm.pbf > /var/lib/mod_tile/data.osm.pbf.info
REPLICATION_TIMESTAMP=$(cat /var/lib/mod_tile/replication_timestamp.txt) osmium fileinfo /data.osm.pbf | grep 'osmosis_replication_timestamp=' | cut -b35-44 > /var/lib/mod_tile/replication_timestamp.txt
REPLICATION_TIMESTAMP=$(cat /var/lib/mod_tile/replication_timestamp.txt)
# initial setup of osmosis workspace (for consecutive updates) # initial setup of osmosis workspace (for consecutive updates)
sudo -u renderer openstreetmap-tiles-update-expire $REPLICATION_TIMESTAMP sudo -u renderer openstreetmap-tiles-update-expire $REPLICATION_TIMESTAMP
fi
# copy polygon file if available # copy polygon file if available
if [ -f /data.poly ]; then if [ -f /data.poly ]; then