Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6e5f4f485d | ||
|
ca4b1acb04 | ||
|
40ebaf7934 | ||
|
bfcc7d7c44 | ||
|
598a48145a | ||
|
d106610e05 | ||
|
ff8655701e | ||
|
a2eceb6bb5 | ||
|
bea77eb8bf | ||
|
33cd142850 | ||
|
c5a6462263 | ||
|
80586aff5f |
@@ -87,6 +87,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 +109,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
|
||||||
|
|
||||||
@@ -143,6 +146,8 @@ COPY postgresql.custom.conf.tmpl /etc/postgresql/10/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/10/main/postgresql.custom.conf.tmpl \
|
||||||
&& echo "\ninclude 'postgresql.custom.conf'" >> /etc/postgresql/10/main/postgresql.conf
|
&& 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
|
||||||
|
|
||||||
# copy update scripts
|
# copy update scripts
|
||||||
COPY openstreetmap-tiles-update-expire /usr/bin/
|
COPY openstreetmap-tiles-update-expire /usr/bin/
|
||||||
|
57
README.md
57
README.md
@@ -63,6 +63,8 @@ docker run \
|
|||||||
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 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`:
|
||||||
@@ -92,6 +94,37 @@ docker run \
|
|||||||
run
|
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/10/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/10/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/).
|
||||||
@@ -108,6 +141,18 @@ docker run \
|
|||||||
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/10/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:
|
||||||
@@ -122,15 +167,7 @@ docker run \
|
|||||||
|
|
||||||
### Flat nodes
|
### 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. This option takes a path to a file that must be persisted so we should first set up a volume with the right permissions:
|
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 -it -v openstreetmap-nodes:/nodes --entrypoint=bash overv/openstreetmap-tile-server
|
|
||||||
$ chown renderer:renderer -R /nodes
|
|
||||||
$ exit
|
|
||||||
```
|
|
||||||
|
|
||||||
You can then use it during the import process as follows:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
@@ -142,6 +179,8 @@ docker run \
|
|||||||
import
|
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).
|
||||||
|
@@ -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 = '*'
|
||||||
|
30
run.sh
30
run.sh
@@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
function CreatePostgressqlConfig()
|
function createPostgresConfig() {
|
||||||
{
|
|
||||||
cp /etc/postgresql/10/main/postgresql.custom.conf.tmpl /etc/postgresql/10/main/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/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
|
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
|
||||||
echo "usage: <import|run>"
|
echo "usage: <import|run>"
|
||||||
echo "commands:"
|
echo "commands:"
|
||||||
@@ -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
|
||||||
@@ -52,11 +56,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} ${OSM2PGSQL_EXTRA_ARGS} -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
|
||||||
@@ -75,9 +82,10 @@ if [ "$1" = "run" ]; then
|
|||||||
fi
|
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
|
||||||
@@ -87,8 +95,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