Merge pull request #25 from pot-gov-pl/master
A lot of changes, please review and choose
This commit is contained in:
commit
2186981cba
129
Dockerfile
129
Dockerfile
@ -3,13 +3,70 @@ FROM ubuntu:18.04
|
||||
# Based on
|
||||
# https://switch2osm.org/manually-building-a-tile-server-18-04-lts/
|
||||
|
||||
# Install dependencies
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y libboost-all-dev git-core tar unzip wget bzip2 build-essential autoconf libtool libxml2-dev libgeos-dev libgeos++-dev libpq-dev libbz2-dev libproj-dev munin-node munin libprotobuf-c0-dev protobuf-c-compiler libfreetype6-dev libtiff5-dev libicu-dev libgdal-dev libcairo-dev libcairomm-1.0-dev apache2 apache2-dev libagg-dev liblua5.2-dev ttf-unifont lua5.1 liblua5.1-dev libgeotiff-epsg
|
||||
|
||||
# Set up environment and renderer user
|
||||
# Set up environment
|
||||
ENV TZ=UTC
|
||||
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 \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y apt-transport-https ca-certificates \
|
||||
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
|
||||
apache2 \
|
||||
apache2-dev \
|
||||
autoconf \
|
||||
build-essential \
|
||||
bzip2 \
|
||||
cmake \
|
||||
fonts-noto-cjk \
|
||||
fonts-noto-hinted \
|
||||
fonts-noto-unhinted \
|
||||
clang \
|
||||
gdal-bin \
|
||||
git-core \
|
||||
libagg-dev \
|
||||
libboost-all-dev \
|
||||
libbz2-dev \
|
||||
libcairo-dev \
|
||||
libcairomm-1.0-dev \
|
||||
libexpat1-dev \
|
||||
libfreetype6-dev \
|
||||
libgdal-dev \
|
||||
libgeos++-dev \
|
||||
libgeos-dev \
|
||||
libgeotiff-epsg \
|
||||
libicu-dev \
|
||||
liblua5.3-dev \
|
||||
libmapnik-dev \
|
||||
libpq-dev \
|
||||
libproj-dev \
|
||||
libprotobuf-c0-dev \
|
||||
libtiff5-dev \
|
||||
libtool \
|
||||
libxml2-dev \
|
||||
lua5.3 \
|
||||
make \
|
||||
mapnik-utils \
|
||||
nodejs \
|
||||
npm \
|
||||
postgis \
|
||||
postgresql-10 \
|
||||
postgresql-10-postgis-2.5 \
|
||||
postgresql-10-postgis-2.5-scripts \
|
||||
postgresql-contrib-10 \
|
||||
protobuf-c-compiler \
|
||||
python-mapnik \
|
||||
sudo \
|
||||
tar \
|
||||
ttf-unifont \
|
||||
unzip \
|
||||
wget \
|
||||
zlib1g-dev \
|
||||
&& apt-get clean autoclean \
|
||||
&& apt-get autoremove --yes \
|
||||
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
|
||||
|
||||
# Set up renderer user
|
||||
RUN adduser --disabled-password --gecos "" renderer
|
||||
USER renderer
|
||||
|
||||
@ -18,34 +75,28 @@ RUN mkdir /home/renderer/src
|
||||
WORKDIR /home/renderer/src
|
||||
RUN git clone https://github.com/openstreetmap/osm2pgsql.git
|
||||
WORKDIR /home/renderer/src/osm2pgsql
|
||||
USER root
|
||||
RUN apt-get install -y make cmake g++ libboost-dev libboost-system-dev libboost-filesystem-dev libexpat1-dev zlib1g-dev libbz2-dev libpq-dev libgeos-dev libgeos++-dev libproj-dev lua5.2 liblua5.2-dev
|
||||
USER renderer
|
||||
RUN mkdir build
|
||||
WORKDIR /home/renderer/src/osm2pgsql/build
|
||||
RUN cmake ..
|
||||
RUN make
|
||||
RUN cmake .. \
|
||||
&& make -j $(nproc)
|
||||
USER root
|
||||
RUN make install
|
||||
USER renderer
|
||||
|
||||
# Install and test Mapnik
|
||||
USER root
|
||||
RUN apt-get -y install autoconf apache2-dev libtool libxml2-dev libbz2-dev libgeos-dev libgeos++-dev libproj-dev gdal-bin libmapnik-dev mapnik-utils python-mapnik
|
||||
USER renderer
|
||||
RUN python -c 'import mapnik'
|
||||
|
||||
# Install mod_tile and renderd
|
||||
WORKDIR /home/renderer/src
|
||||
RUN git clone -b switch2osm https://github.com/SomeoneElseOSM/mod_tile.git
|
||||
WORKDIR /home/renderer/src/mod_tile
|
||||
RUN ./autogen.sh
|
||||
RUN ./configure
|
||||
RUN make
|
||||
RUN ./autogen.sh \
|
||||
&& ./configure \
|
||||
&& make -j $(nproc)
|
||||
USER root
|
||||
RUN make install
|
||||
RUN make install-mod_tile
|
||||
RUN ldconfig
|
||||
RUN make -j $(nproc) install \
|
||||
&& make -j $(nproc) install-mod_tile \
|
||||
&& ldconfig
|
||||
USER renderer
|
||||
|
||||
# Configure stylesheet
|
||||
@ -53,46 +104,42 @@ WORKDIR /home/renderer/src
|
||||
RUN git clone https://github.com/gravitystorm/openstreetmap-carto.git
|
||||
WORKDIR /home/renderer/src/openstreetmap-carto
|
||||
USER root
|
||||
RUN apt-get install -y npm nodejs
|
||||
RUN npm install -g carto
|
||||
USER renderer
|
||||
RUN carto -v
|
||||
RUN carto project.mml > mapnik.xml
|
||||
|
||||
# Load shapefiles
|
||||
WORKDIR /home/renderer/src/openstreetmap-carto
|
||||
RUN scripts/get-shapefiles.py
|
||||
|
||||
# Install fonts
|
||||
USER root
|
||||
RUN apt-get install -y fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted ttf-unifont
|
||||
USER renderer
|
||||
|
||||
# Configure renderd
|
||||
USER root
|
||||
RUN sed -i 's/renderaccount/renderer/g' /usr/local/etc/renderd.conf
|
||||
RUN sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf
|
||||
RUN sed -i 's/renderaccount/renderer/g' /usr/local/etc/renderd.conf \
|
||||
&& sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf
|
||||
USER renderer
|
||||
|
||||
# Configure Apache
|
||||
USER root
|
||||
RUN mkdir /var/lib/mod_tile
|
||||
RUN chown renderer /var/lib/mod_tile
|
||||
RUN mkdir /var/run/renderd
|
||||
RUN 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 a2enconf mod_tile
|
||||
RUN mkdir /var/lib/mod_tile \
|
||||
&& chown renderer /var/lib/mod_tile \
|
||||
&& mkdir /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 \
|
||||
&& a2enconf mod_tile
|
||||
COPY apache.conf /etc/apache2/sites-available/000-default.conf
|
||||
USER renderer
|
||||
COPY leaflet-demo.html /var/www/html/index.html
|
||||
RUN ln -sf /proc/1/fd/1 /var/log/apache2/access.log \
|
||||
&& ln -sf /proc/1/fd/2 /var/log/apache2/error.log
|
||||
|
||||
# Install PostgreSQL
|
||||
USER root
|
||||
RUN apt-get install -y postgresql postgresql-contrib postgis postgresql-10-postgis-2.4
|
||||
USER renderer
|
||||
# Configure PosgtreSQL
|
||||
COPY postgresql.custom.conf /etc/postgresql/10/main/
|
||||
RUN chown -R postgres:postgres /var/lib/postgresql \
|
||||
&& chown postgres:postgres /etc/postgresql/10/main/postgresql.custom.conf \
|
||||
&& echo "\ninclude 'postgresql.custom.conf'" >> /etc/postgresql/10/main/postgresql.conf
|
||||
|
||||
# Start running
|
||||
USER root
|
||||
RUN apt-get install -y sudo
|
||||
COPY run.sh /
|
||||
ENTRYPOINT ["/run.sh"]
|
||||
CMD []
|
||||
|
||||
EXPOSE 80 5432
|
||||
|
15
README.md
15
README.md
@ -35,6 +35,21 @@ 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 -d overv/openstreetmap-tile-server run
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### ERROR: could not resize shared memory segment
|
||||
|
||||
If you encounter such entries in the log, it will mean that the default shared memory limit (64 MB) is too low for the container and it should be raised:
|
||||
|
||||
renderd[126]: ERROR: failed to render TILE ajt 6 32-39 16-23,
|
||||
renderd[126]: reason: Postgis Plugin: ERROR: could not resize shared memory segment
|
||||
|
||||
To raise it use `--shm-size` parameter. For example:
|
||||
|
||||
docker run -p 80:80 -v openstreetmap-data:/var/lib/postgresql/10/main --shm-size="192m" -d overv/openstreetmap-tile-server 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.
|
||||
|
||||
## License
|
||||
|
||||
```
|
||||
|
@ -25,7 +25,7 @@
|
||||
<script>
|
||||
var map = L.map('map').setView([0, 0], 3);
|
||||
|
||||
L.tileLayer('http://localhost/tile/{z}/{x}/{y}.png', {
|
||||
L.tileLayer('/tile/{z}/{x}/{y}.png', {
|
||||
maxZoom: 18,
|
||||
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
|
||||
id: 'base'
|
||||
|
24
postgresql.custom.conf
Normal file
24
postgresql.custom.conf
Normal file
@ -0,0 +1,24 @@
|
||||
# Suggested minimal settings from
|
||||
# https://ircama.github.io/osm-carto-tutorials/tile-server-ubuntu/
|
||||
|
||||
shared_buffers = 128MB
|
||||
min_wal_size = 1GB
|
||||
max_wal_size = 2GB
|
||||
work_mem = 32MB
|
||||
maintenance_work_mem = 256MB
|
||||
|
||||
# Suggested settings from
|
||||
# https://github.com/openstreetmap/chef/blob/master/roles/tile.rb#L38-L45
|
||||
|
||||
max_connections = 250
|
||||
temp_buffers = 32MB
|
||||
work_mem = 128MB
|
||||
wal_buffers = 1024kB
|
||||
wal_writer_delay = 500ms
|
||||
commit_delay = 10000
|
||||
# checkpoint_segments = 60 # unrecognized in psql 10.7.1
|
||||
max_wal_size = 2880MB
|
||||
random_page_cost = 1.1
|
||||
track_activity_query_size = 16384
|
||||
autovacuum_vacuum_scale_factor = 0.05
|
||||
autovacuum_analyze_scale_factor = 0.02
|
3
run.sh
3
run.sh
@ -12,6 +12,7 @@ fi
|
||||
|
||||
if [ "$1" = "import" ]; then
|
||||
# Initialize PostgreSQL
|
||||
sudo -u postgres echo "autovacuum = off" >> /etc/postgresql/10/main/postgresql.custom.conf
|
||||
service postgresql start
|
||||
sudo -u postgres createuser renderer
|
||||
sudo -u postgres createdb -E UTF8 -O renderer gis
|
||||
@ -28,6 +29,7 @@ if [ "$1" = "import" ]; then
|
||||
|
||||
# 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
|
||||
service postgresql stop
|
||||
|
||||
exit 0
|
||||
fi
|
||||
@ -42,6 +44,7 @@ if [ "$1" = "run" ]; then
|
||||
|
||||
# Run
|
||||
sudo -u renderer renderd -f -c /usr/local/etc/renderd.conf
|
||||
service postgresql stop
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user