Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
789ff772be | ||
|
64c66a7d0b | ||
|
626158f677 | ||
|
ca1626a9fc | ||
|
101bb62e45 | ||
|
e249f30d40 | ||
|
6e5f4f485d | ||
|
ca4b1acb04 | ||
|
40ebaf7934 | ||
|
bfcc7d7c44 | ||
|
598a48145a | ||
|
d106610e05 | ||
|
ff8655701e | ||
|
a2eceb6bb5 | ||
|
bea77eb8bf | ||
|
33cd142850 | ||
|
c5a6462263 | ||
|
80586aff5f | ||
|
b82e37b9b5 | ||
|
451f335bc5 | ||
|
8744ab2792 | ||
|
31bf2d718b | ||
|
fcc6168253 |
42
Dockerfile
42
Dockerfile
@@ -10,7 +10,10 @@ 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 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 update \
|
||||||
&& apt-get install -y apt-transport-https ca-certificates \
|
&& apt-get install -y apt-transport-https ca-certificates \
|
||||||
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
|
&& 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-hinted \
|
||||||
fonts-noto-unhinted \
|
fonts-noto-unhinted \
|
||||||
clang \
|
clang \
|
||||||
|
gcc \
|
||||||
gdal-bin \
|
gdal-bin \
|
||||||
|
make \
|
||||||
git-core \
|
git-core \
|
||||||
libagg-dev \
|
libagg-dev \
|
||||||
libboost-all-dev \
|
libboost-all-dev \
|
||||||
@@ -52,10 +57,9 @@ RUN echo "deb [ allow-insecure=yes ] http://apt.postgresql.org/pub/repos/apt/ bi
|
|||||||
nodejs \
|
nodejs \
|
||||||
npm \
|
npm \
|
||||||
postgis \
|
postgis \
|
||||||
postgresql-10 \
|
postgresql-12 \
|
||||||
postgresql-10-postgis-2.5 \
|
postgresql-server-dev-12 \
|
||||||
postgresql-10-postgis-2.5-scripts \
|
postgresql-contrib-12 \
|
||||||
postgresql-contrib-10 \
|
|
||||||
protobuf-c-compiler \
|
protobuf-c-compiler \
|
||||||
python-mapnik \
|
python-mapnik \
|
||||||
sudo \
|
sudo \
|
||||||
@@ -72,6 +76,11 @@ RUN echo "deb [ allow-insecure=yes ] http://apt.postgresql.org/pub/repos/apt/ bi
|
|||||||
&& apt-get autoremove --yes \
|
&& apt-get autoremove --yes \
|
||||||
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
|
&& 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
|
# Set up renderer user
|
||||||
RUN adduser --disabled-password --gecos "" renderer
|
RUN adduser --disabled-password --gecos "" renderer
|
||||||
USER renderer
|
USER renderer
|
||||||
@@ -87,6 +96,8 @@ RUN cmake .. \
|
|||||||
&& make -j $(nproc)
|
&& make -j $(nproc)
|
||||||
USER root
|
USER root
|
||||||
RUN make install
|
RUN make install
|
||||||
|
RUN mkdir /nodes \
|
||||||
|
&& chown renderer:renderer /nodes
|
||||||
USER renderer
|
USER renderer
|
||||||
|
|
||||||
# Install and test Mapnik
|
# Install and test Mapnik
|
||||||
@@ -107,10 +118,11 @@ USER renderer
|
|||||||
|
|
||||||
# Configure stylesheet
|
# Configure stylesheet
|
||||||
WORKDIR /home/renderer/src
|
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
|
WORKDIR /home/renderer/src/openstreetmap-carto
|
||||||
USER root
|
USER root
|
||||||
RUN npm install -g carto
|
RUN npm install -g carto@0.18.2
|
||||||
USER renderer
|
USER renderer
|
||||||
RUN carto project.mml > mapnik.xml
|
RUN carto project.mml > mapnik.xml
|
||||||
|
|
||||||
@@ -131,17 +143,19 @@ RUN mkdir /var/lib/mod_tile \
|
|||||||
&& mkdir /var/run/renderd \
|
&& mkdir /var/run/renderd \
|
||||||
&& chown renderer /var/run/renderd
|
&& chown renderer /var/run/renderd
|
||||||
RUN echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \
|
RUN echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \
|
||||||
&& a2enconf mod_tile
|
&& echo "LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so" >> /etc/apache2/conf-available/mod_headers.conf \
|
||||||
|
&& a2enconf mod_tile && a2enconf mod_headers
|
||||||
COPY apache.conf /etc/apache2/sites-available/000-default.conf
|
COPY apache.conf /etc/apache2/sites-available/000-default.conf
|
||||||
COPY leaflet-demo.html /var/www/html/index.html
|
COPY leaflet-demo.html /var/www/html/index.html
|
||||||
RUN ln -sf /proc/1/fd/1 /var/log/apache2/access.log \
|
RUN ln -sf /dev/stdout /var/log/apache2/access.log \
|
||||||
&& ln -sf /proc/1/fd/2 /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 \
|
||||||
|
&& echo "host all all ::/0 md5" >> /etc/postgresql/12/main/pg_hba.conf
|
||||||
|
|
||||||
# copy update scripts
|
# copy update scripts
|
||||||
COPY openstreetmap-tiles-update-expire /usr/bin/
|
COPY openstreetmap-tiles-update-expire /usr/bin/
|
||||||
@@ -155,6 +169,8 @@ RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \
|
|||||||
USER renderer
|
USER renderer
|
||||||
RUN cd ~/src \
|
RUN cd ~/src \
|
||||||
&& git clone https://github.com/zverik/regional \
|
&& git clone https://github.com/zverik/regional \
|
||||||
|
&& cd regional \
|
||||||
|
&& git checkout 612fe3e040d8bb70d2ab3b133f3b2cfc6c940520 \
|
||||||
&& chmod u+x ~/src/regional/trim_osc.py
|
&& chmod u+x ~/src/regional/trim_osc.py
|
||||||
|
|
||||||
# Start running
|
# Start running
|
||||||
|
4
Makefile
4
Makefile
@@ -8,5 +8,5 @@ push: build
|
|||||||
|
|
||||||
test: build
|
test: build
|
||||||
docker volume create openstreetmap-data
|
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/12/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 -p 80:80 -d overv/openstreetmap-tile-server run
|
||||||
|
103
README.md
103
README.md
@@ -13,7 +13,7 @@ Next, download an .osm.pbf extract from geofabrik.de for the region that you're
|
|||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
|
-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 \
|
overv/openstreetmap-tile-server \
|
||||||
import
|
import
|
||||||
```
|
```
|
||||||
@@ -22,18 +22,19 @@ 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/10/main \
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
overv/openstreetmap-tile-server \
|
overv/openstreetmap-tile-server \
|
||||||
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
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ Run the server like this:
|
|||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-p 80:80 \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/10/main \
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
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 volume create openstreetmap-rendered-tiles
|
||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-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 \
|
-v openstreetmap-rendered-tiles:/var/lib/mod_tile \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
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)
|
### 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 \
|
||||||
-p 80:80 \
|
-p 80:80 \
|
||||||
-e UPDATES=enabled \
|
-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 \
|
-v openstreetmap-rendered-tiles:/var/lib/mod_tile \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
@@ -79,6 +82,50 @@ docker run \
|
|||||||
|
|
||||||
This will enable a background process that automatically downloads changes from the OpenStreetMap server, filters them for the relevant region polygon you specified, updates the database and finally marks the affected tiles for rerendering.
|
This will enable a background process that automatically downloads changes from the OpenStreetMap server, filters them for the relevant region polygon you specified, updates the database and finally marks the affected tiles for rerendering.
|
||||||
|
|
||||||
|
### Cross-origin resource sharing
|
||||||
|
|
||||||
|
To enable the `Access-Control-Allow-Origin` header to be able to retrieve tiles from other domains, simply set the `ALLOW_CORS` variable to `1`:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run \
|
||||||
|
-p 80:80 \
|
||||||
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
|
-e ALLOW_CORS=1 \
|
||||||
|
-d overv/openstreetmap-tile-server \
|
||||||
|
run
|
||||||
|
```
|
||||||
|
|
||||||
|
### Connecting to Postgres
|
||||||
|
|
||||||
|
To connect to the PostgreSQL database inside the container, make sure to expose port 5432:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run \
|
||||||
|
-p 80:80 \
|
||||||
|
-p 5432:5432 \
|
||||||
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
|
-d overv/openstreetmap-tile-server \
|
||||||
|
run
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the user `renderer` and the database `gis` to connect.
|
||||||
|
|
||||||
|
```
|
||||||
|
psql -h localhost -U renderer gis
|
||||||
|
```
|
||||||
|
|
||||||
|
The default password is `renderer`, but it can be changed using the `PGPASSWORD` environment variable:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run \
|
||||||
|
-p 80:80 \
|
||||||
|
-p 5432:5432 \
|
||||||
|
-e PGPASSWORD=secret \
|
||||||
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
|
-d overv/openstreetmap-tile-server \
|
||||||
|
run
|
||||||
|
```
|
||||||
|
|
||||||
## Performance tuning and tweaking
|
## Performance tuning and tweaking
|
||||||
|
|
||||||
Details for update procedure and invoked scripts can be found here [link](https://ircama.github.io/osm-carto-tutorials/updating-data/).
|
Details for update procedure and invoked scripts can be found here [link](https://ircama.github.io/osm-carto-tutorials/updating-data/).
|
||||||
@@ -90,10 +137,23 @@ The import and tile serving processes use 4 threads by default, but this number
|
|||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-p 80:80 \
|
||||||
-e THREADS=24 \
|
-e THREADS=24 \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/10/main \
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### CACHE
|
||||||
|
|
||||||
|
The import and tile serving processes use 800 MB RAM cache by default, but this number can be changed by option -C. For example:
|
||||||
|
```
|
||||||
|
docker run \
|
||||||
|
-p 80:80 \
|
||||||
|
-e "OSM2PGSQL_EXTRA_ARGS=-C 4096" \
|
||||||
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
|
-d overv/openstreetmap-tile-server \
|
||||||
|
run
|
||||||
|
```
|
||||||
|
|
||||||
### AUTOVACUUM
|
### AUTOVACUUM
|
||||||
|
|
||||||
The database use the autovacuum feature by default. This behavior can be changed with `AUTOVACUUM` environment variable. For example:
|
The database use the autovacuum feature by default. This behavior can be changed with `AUTOVACUUM` environment variable. For example:
|
||||||
@@ -101,10 +161,27 @@ The database use the autovacuum feature by default. This behavior can be changed
|
|||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-p 80:80 \
|
||||||
-e AUTOVACUUM=off \
|
-e AUTOVACUUM=off \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/10/main \
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Flat nodes
|
||||||
|
|
||||||
|
If you are planning to import the entire planet or you are running into memory errors then you may want to enable the `--flat-nodes` option for osm2pgsql. You can then use it during the import process as follows:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run \
|
||||||
|
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
|
||||||
|
-v openstreetmap-nodes:/nodes \
|
||||||
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
|
-e "OSM2PGSQL_EXTRA_ARGS=--flat-nodes /nodes/flat_nodes.bin" \
|
||||||
|
overv/openstreetmap-tile-server \
|
||||||
|
import
|
||||||
|
```
|
||||||
|
|
||||||
|
>Note that if you use a folder other than `/nodes` then you must make sure that you manually set the owner to `renderer`!
|
||||||
|
|
||||||
### Benchmarks
|
### Benchmarks
|
||||||
|
|
||||||
You can find an example of the import performance to expect with this image on the [OpenStreetMap wiki](https://wiki.openstreetmap.org/wiki/Osm2pgsql/benchmarks#debian_9_.2F_openstreetmap-tile-server).
|
You can find an example of the import performance to expect with this image on the [OpenStreetMap wiki](https://wiki.openstreetmap.org/wiki/Osm2pgsql/benchmarks#debian_9_.2F_openstreetmap-tile-server).
|
||||||
@@ -122,13 +199,17 @@ To raise it use `--shm-size` parameter. For example:
|
|||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-p 80:80 \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/10/main \
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
--shm-size="192m" \
|
--shm-size="192m" \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
For too high values you may notice excessive CPU load and memory usage. It might be that you will have to experimentally find the best values for yourself.
|
For too high values you may notice excessive CPU load and memory usage. It might be that you will have to experimentally find the best values for yourself.
|
||||||
|
|
||||||
|
### The import process unexpectedly exits
|
||||||
|
|
||||||
|
You may be running into problems with memory usage during the import. Have a look at the "Flat nodes" section in this README.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@@ -10,4 +10,8 @@
|
|||||||
|
|
||||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||||
|
|
||||||
|
<IfDefine ALLOW_CORS>
|
||||||
|
Header set Access-Control-Allow-Origin "*"
|
||||||
|
</IfDefine>
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
@@ -22,7 +22,7 @@ OSM2PGSQL_BIN=osm2pgsql
|
|||||||
TRIM_BIN=/home/$ACCOUNT/src/regional/trim_osc.py
|
TRIM_BIN=/home/$ACCOUNT/src/regional/trim_osc.py
|
||||||
|
|
||||||
DBNAME=gis
|
DBNAME=gis
|
||||||
OSM2PGSQL_OPTIONS="-d $DBNAME -G --hstore --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua -C 2048 --number-processes ${THREADS:-4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style"
|
OSM2PGSQL_OPTIONS="-d $DBNAME -G --hstore ${OSM2PGSQL_EXTRA_ARGS} --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua --number-processes ${THREADS:-4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style"
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# When using trim_osc.py we can define either a bounding box (such as this
|
# When using trim_osc.py we can define either a bounding box (such as this
|
||||||
|
@@ -21,3 +21,5 @@ random_page_cost = 1.1
|
|||||||
track_activity_query_size = 16384
|
track_activity_query_size = 16384
|
||||||
autovacuum_vacuum_scale_factor = 0.05
|
autovacuum_vacuum_scale_factor = 0.05
|
||||||
autovacuum_analyze_scale_factor = 0.02
|
autovacuum_analyze_scale_factor = 0.02
|
||||||
|
|
||||||
|
listen_addresses = '*'
|
||||||
|
57
run.sh
57
run.sh
@@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
function CreatePostgressqlConfig()
|
function createPostgresConfig() {
|
||||||
{
|
cp /etc/postgresql/12/main/postgresql.custom.conf.tmpl /etc/postgresql/12/main/conf.d/postgresql.custom.conf
|
||||||
cp /etc/postgresql/10/main/postgresql.custom.conf.tmpl /etc/postgresql/10/main/postgresql.custom.conf
|
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/12/main/conf.d/postgresql.custom.conf
|
||||||
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/10/main/postgresql.custom.conf
|
cat /etc/postgresql/12/main/conf.d/postgresql.custom.conf
|
||||||
cat /etc/postgresql/10/main/postgresql.custom.conf
|
}
|
||||||
|
|
||||||
|
function setPostgresPassword() {
|
||||||
|
sudo -u postgres psql -c "ALTER USER renderer PASSWORD '${PGPASSWORD:-renderer}'"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$#" -ne 1 ]; then
|
if [ "$#" -ne 1 ]; then
|
||||||
@@ -22,7 +25,7 @@ fi
|
|||||||
|
|
||||||
if [ "$1" = "import" ]; then
|
if [ "$1" = "import" ]; then
|
||||||
# Initialize PostgreSQL
|
# Initialize PostgreSQL
|
||||||
CreatePostgressqlConfig
|
createPostgresConfig
|
||||||
service postgresql start
|
service postgresql start
|
||||||
sudo -u postgres createuser renderer
|
sudo -u postgres createuser renderer
|
||||||
sudo -u postgres createdb -E UTF8 -O renderer gis
|
sudo -u postgres createdb -E UTF8 -O renderer gis
|
||||||
@@ -30,6 +33,7 @@ if [ "$1" = "import" ]; then
|
|||||||
sudo -u postgres psql -d gis -c "CREATE EXTENSION hstore;"
|
sudo -u postgres psql -d gis -c "CREATE EXTENSION hstore;"
|
||||||
sudo -u postgres psql -d gis -c "ALTER TABLE geometry_columns OWNER TO renderer;"
|
sudo -u postgres psql -d gis -c "ALTER TABLE geometry_columns OWNER TO renderer;"
|
||||||
sudo -u postgres psql -d gis -c "ALTER TABLE spatial_ref_sys OWNER TO renderer;"
|
sudo -u postgres psql -d gis -c "ALTER TABLE spatial_ref_sys OWNER TO renderer;"
|
||||||
|
setPostgresPassword
|
||||||
|
|
||||||
# Download Luxembourg as sample if no data is provided
|
# Download Luxembourg as sample if no data is provided
|
||||||
if [ ! -f /data.osm.pbf ]; then
|
if [ ! -f /data.osm.pbf ]; then
|
||||||
@@ -38,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
|
||||||
@@ -52,11 +58,14 @@ if [ "$1" = "import" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Import data
|
# Import data
|
||||||
sudo -u renderer osm2pgsql -d gis --create --slim -G --hstore --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua -C 2048 --number-processes ${THREADS:-4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style /data.osm.pbf
|
sudo -u renderer osm2pgsql -d gis --create --slim -G --hstore --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua --number-processes ${THREADS:-4} ${OSM2PGSQL_EXTRA_ARGS} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style /data.osm.pbf
|
||||||
|
|
||||||
# Create indexes
|
# Create indexes
|
||||||
sudo -u postgres psql -d gis -f indexes.sql
|
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
|
service postgresql stop
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
@@ -65,14 +74,20 @@ fi
|
|||||||
if [ "$1" = "run" ]; then
|
if [ "$1" = "run" ]; then
|
||||||
# Clean /tmp
|
# Clean /tmp
|
||||||
rm -rf /tmp/*
|
rm -rf /tmp/*
|
||||||
|
|
||||||
# Fix postgres data privileges
|
# Fix postgres data privileges
|
||||||
chown postgres:postgres /var/lib/postgresql -R
|
chown postgres:postgres /var/lib/postgresql -R
|
||||||
|
|
||||||
|
# Configure Apache CORS
|
||||||
|
if [ "$ALLOW_CORS" == "1" ]; then
|
||||||
|
echo "export APACHE_ARGUMENTS='-D ALLOW_CORS'" >> /etc/apache2/envvars
|
||||||
|
fi
|
||||||
|
|
||||||
# Initialize PostgreSQL and Apache
|
# Initialize PostgreSQL and Apache
|
||||||
CreatePostgressqlConfig
|
createPostgresConfig
|
||||||
service postgresql start
|
service postgresql start
|
||||||
service apache2 restart
|
service apache2 restart
|
||||||
|
setPostgresPassword
|
||||||
|
|
||||||
# Configure renderd threads
|
# Configure renderd threads
|
||||||
sed -i -E "s/num_threads=[0-9]+/num_threads=${THREADS:-4}/g" /usr/local/etc/renderd.conf
|
sed -i -E "s/num_threads=[0-9]+/num_threads=${THREADS:-4}/g" /usr/local/etc/renderd.conf
|
||||||
@@ -82,8 +97,16 @@ if [ "$1" = "run" ]; then
|
|||||||
/etc/init.d/cron start
|
/etc/init.d/cron start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run
|
# Run while handling docker stop's SIGTERM
|
||||||
sudo -u renderer renderd -f -c /usr/local/etc/renderd.conf
|
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
|
service postgresql stop
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Reference in New Issue
Block a user