Compare commits
96 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
cfff8fca63 | ||
|
85eaca5c79 | ||
|
9679b29b50 | ||
|
8f2c575ad6 | ||
|
75e7714f20 | ||
|
ec500a2cde | ||
|
affae5a92d | ||
|
a204fb85fd | ||
|
7636079b4d | ||
|
2ae828c52b | ||
|
6fb62935f3 | ||
|
953232051f | ||
|
bedff2a880 | ||
|
e79901b7dd | ||
|
5a059ab0a5 | ||
|
bcf2cfcada | ||
|
0e1db36457 | ||
|
677b52468e | ||
|
1093734e1b | ||
|
9fb0743c51 | ||
|
19cb75baa4 | ||
|
82bc6a35a3 | ||
|
44490df8c5 | ||
|
6dc84f1d26 | ||
|
26a4b9f239 | ||
|
2754592d1c | ||
|
e838310073 | ||
|
cca2d00a78 | ||
|
cc5b50b050 | ||
|
d8f2fc14e4 | ||
|
1b437e143f | ||
|
acedcce53d | ||
|
e15dee4665 | ||
|
83f26e1abe | ||
|
5a1b2a6b06 | ||
|
6d0e8070f5 | ||
|
2a69c977c9 | ||
|
5300472417 | ||
|
f9a29fb23b | ||
|
52c89b4775 | ||
|
0bb62b77d3 | ||
|
0a5ac2a018 | ||
|
f0f36a6c9b | ||
|
b192fabac3 | ||
|
f2971fa97e | ||
|
0d789b883d | ||
|
99484a505b | ||
|
ac609febcc | ||
|
dafb4610cd | ||
|
a90f8f1d8c | ||
|
515dd2a18c | ||
|
18c97f52bf | ||
|
e9a26ddded | ||
|
d0428523b5 | ||
|
4ca2e8f1e5 | ||
|
17a2c6d631 | ||
|
d7922429f3 | ||
|
837a38df04 | ||
|
f69bcd2540 | ||
|
f77c926ee5 | ||
|
bae840f240 | ||
|
e0f7438dab | ||
|
637e821888 | ||
|
e8e95c6001 | ||
|
d8ccc2c026 | ||
|
b71e7a6aba | ||
|
62a972736a | ||
|
f9f1047400 | ||
|
fa4b0eba0b | ||
|
69cb804609 | ||
|
efc2cb1e2a | ||
|
6de21a4595 | ||
|
868d2fae0a | ||
|
0527120c30 | ||
|
8bac516eb1 | ||
|
c8a79a19e4 | ||
|
92708df534 | ||
|
879e5f25ab | ||
|
010f87d711 | ||
|
789ff772be | ||
|
64c66a7d0b | ||
|
626158f677 | ||
|
ca1626a9fc | ||
|
101bb62e45 | ||
|
e249f30d40 | ||
|
6e5f4f485d | ||
|
ca4b1acb04 | ||
|
40ebaf7934 | ||
|
bfcc7d7c44 | ||
|
598a48145a | ||
|
d106610e05 | ||
|
ff8655701e | ||
|
a2eceb6bb5 | ||
|
bea77eb8bf | ||
|
33cd142850 | ||
|
c5a6462263 |
28
.travis.yml
Normal file
28
.travis.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
os: linux
|
||||||
|
language: minimal
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
# DOCKER_USERNAME/DOCKER_PASSWORD have been configured in Travis CI
|
||||||
|
# env:
|
||||||
|
before_install:
|
||||||
|
- echo "Before install"
|
||||||
|
before_script:
|
||||||
|
- docker pull overv/openstreetmap-tile-server || true
|
||||||
|
script:
|
||||||
|
- docker build --pull --cache-from overv/openstreetmap-tile-server --tag overv/openstreetmap-tile-server .
|
||||||
|
- docker volume create openstreetmap-data
|
||||||
|
- docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main overv/openstreetmap-tile-server import
|
||||||
|
- docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main -p 8080:80 -d overv/openstreetmap-tile-server run
|
||||||
|
- sleep 30
|
||||||
|
- make DOCKER_IMAGE=overv/openstreetmap-tile-server stop
|
||||||
|
after_script:
|
||||||
|
- docker images
|
||||||
|
after_success:
|
||||||
|
- if [[ "$TRAVIS_BRANCH" == "master" ]];
|
||||||
|
then
|
||||||
|
docker images ;
|
||||||
|
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ;
|
||||||
|
docker push overv/openstreetmap-tile-server ;
|
||||||
|
fi
|
||||||
|
notifications:
|
||||||
|
email: true
|
158
Dockerfile
158
Dockerfile
@@ -1,7 +1,7 @@
|
|||||||
FROM ubuntu:18.04
|
FROM ubuntu:20.04
|
||||||
|
|
||||||
# Based on
|
# Based on
|
||||||
# https://switch2osm.org/manually-building-a-tile-server-18-04-lts/
|
# https://switch2osm.org/serving-tiles/manually-building-a-tile-server-18-04-lts/
|
||||||
|
|
||||||
# Set up environment
|
# Set up environment
|
||||||
ENV TZ=UTC
|
ENV TZ=UTC
|
||||||
@@ -10,24 +10,31 @@ 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 -y wget gnupg2 lsb-core apt-transport-https ca-certificates curl \
|
||||||
|
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
|
||||||
|
&& echo "deb [ trusted=yes ] https://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list \
|
||||||
|
&& wget --quiet -O - https://deb.nodesource.com/setup_14.x | bash - \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
&& apt-get install -y apt-transport-https ca-certificates \
|
&& apt-get install -y nodejs
|
||||||
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
|
|
||||||
|
RUN apt-get install -y --no-install-recommends \
|
||||||
apache2 \
|
apache2 \
|
||||||
apache2-dev \
|
apache2-dev \
|
||||||
autoconf \
|
autoconf \
|
||||||
build-essential \
|
build-essential \
|
||||||
bzip2 \
|
bzip2 \
|
||||||
cmake \
|
cmake \
|
||||||
|
cron \
|
||||||
fonts-noto-cjk \
|
fonts-noto-cjk \
|
||||||
fonts-noto-hinted \
|
fonts-noto-hinted \
|
||||||
fonts-noto-unhinted \
|
fonts-noto-unhinted \
|
||||||
clang \
|
gcc \
|
||||||
gdal-bin \
|
gdal-bin \
|
||||||
git-core \
|
git-core \
|
||||||
libagg-dev \
|
libagg-dev \
|
||||||
libboost-all-dev \
|
libboost-filesystem-dev \
|
||||||
|
libboost-system-dev \
|
||||||
libbz2-dev \
|
libbz2-dev \
|
||||||
libcairo-dev \
|
libcairo-dev \
|
||||||
libcairomm-1.0-dev \
|
libcairomm-1.0-dev \
|
||||||
@@ -36,101 +43,108 @@ RUN echo "deb [ allow-insecure=yes ] http://apt.postgresql.org/pub/repos/apt/ bi
|
|||||||
libgdal-dev \
|
libgdal-dev \
|
||||||
libgeos++-dev \
|
libgeos++-dev \
|
||||||
libgeos-dev \
|
libgeos-dev \
|
||||||
libgeotiff-epsg \
|
|
||||||
libicu-dev \
|
libicu-dev \
|
||||||
liblua5.3-dev \
|
liblua5.3-dev \
|
||||||
libmapnik-dev \
|
libmapnik-dev \
|
||||||
libpq-dev \
|
libpq-dev \
|
||||||
libproj-dev \
|
libproj-dev \
|
||||||
libprotobuf-c0-dev \
|
libprotobuf-c-dev \
|
||||||
libtiff5-dev \
|
libtiff5-dev \
|
||||||
libtool \
|
libtool \
|
||||||
libxml2-dev \
|
libxml2-dev \
|
||||||
lua5.3 \
|
lua5.3 \
|
||||||
make \
|
make \
|
||||||
mapnik-utils \
|
mapnik-utils \
|
||||||
nodejs \
|
osmium-tool \
|
||||||
npm \
|
osmosis \
|
||||||
postgis \
|
postgis \
|
||||||
postgresql-10 \
|
postgresql-12 \
|
||||||
postgresql-10-postgis-2.5 \
|
postgresql-contrib-12 \
|
||||||
postgresql-10-postgis-2.5-scripts \
|
postgresql-server-dev-12 \
|
||||||
postgresql-contrib-10 \
|
|
||||||
protobuf-c-compiler \
|
protobuf-c-compiler \
|
||||||
python-mapnik \
|
python-is-python3 \
|
||||||
|
python3-mapnik \
|
||||||
|
python3-lxml \
|
||||||
|
python3-psycopg2 \
|
||||||
|
python3-shapely \
|
||||||
|
python3-pip \
|
||||||
sudo \
|
sudo \
|
||||||
tar \
|
tar \
|
||||||
ttf-unifont \
|
ttf-unifont \
|
||||||
unzip \
|
unzip \
|
||||||
wget \
|
wget \
|
||||||
zlib1g-dev \
|
zlib1g-dev \
|
||||||
osmosis \
|
|
||||||
osmium-tool \
|
|
||||||
cron \
|
|
||||||
python3-psycopg2 python3-shapely python3-lxml \
|
|
||||||
&& apt-get clean autoclean \
|
&& apt-get clean autoclean \
|
||||||
&& apt-get autoremove --yes \
|
&& apt-get autoremove --yes \
|
||||||
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
|
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
|
||||||
|
|
||||||
|
# Install python libraries
|
||||||
|
RUN pip3 install requests \
|
||||||
|
&& pip3 install pyyaml
|
||||||
|
|
||||||
|
# Set up PostGIS
|
||||||
|
RUN wget https://download.osgeo.org/postgis/source/postgis-3.1.1.tar.gz -O postgis.tar.gz \
|
||||||
|
&& mkdir -p postgis_src \
|
||||||
|
&& tar -xvzf postgis.tar.gz --strip 1 -C postgis_src \
|
||||||
|
&& rm postgis.tar.gz \
|
||||||
|
&& cd postgis_src \
|
||||||
|
&& ./configure \
|
||||||
|
&& make -j $(nproc) \
|
||||||
|
&& make -j $(nproc) install \
|
||||||
|
&& cd .. && rm -rf postgis_src
|
||||||
|
|
||||||
# Set up renderer user
|
# Set up renderer user
|
||||||
RUN adduser --disabled-password --gecos "" renderer
|
RUN adduser --disabled-password --gecos "" renderer
|
||||||
USER renderer
|
|
||||||
|
|
||||||
# Install latest osm2pgsql
|
# Install latest osm2pgsql
|
||||||
RUN mkdir /home/renderer/src
|
RUN mkdir -p /home/renderer/src \
|
||||||
WORKDIR /home/renderer/src
|
&& cd /home/renderer/src \
|
||||||
RUN git clone https://github.com/openstreetmap/osm2pgsql.git
|
&& git clone -b master https://github.com/openstreetmap/osm2pgsql.git --depth 1 \
|
||||||
WORKDIR /home/renderer/src/osm2pgsql
|
&& cd /home/renderer/src/osm2pgsql \
|
||||||
RUN mkdir build
|
&& rm -rf .git \
|
||||||
WORKDIR /home/renderer/src/osm2pgsql/build
|
&& mkdir build \
|
||||||
RUN cmake .. \
|
&& cd build \
|
||||||
&& make -j $(nproc)
|
&& cmake .. \
|
||||||
USER root
|
&& make -j $(nproc) \
|
||||||
RUN make install
|
&& make -j $(nproc) install \
|
||||||
USER renderer
|
&& mkdir /nodes \
|
||||||
|
&& chown renderer:renderer /nodes \
|
||||||
# Install and test Mapnik
|
&& rm -rf /home/renderer/src/osm2pgsql
|
||||||
RUN python -c 'import mapnik'
|
|
||||||
|
|
||||||
# Install mod_tile and renderd
|
# Install mod_tile and renderd
|
||||||
WORKDIR /home/renderer/src
|
RUN mkdir -p /home/renderer/src \
|
||||||
RUN git clone -b switch2osm https://github.com/SomeoneElseOSM/mod_tile.git
|
&& cd /home/renderer/src \
|
||||||
WORKDIR /home/renderer/src/mod_tile
|
&& git clone -b switch2osm https://github.com/SomeoneElseOSM/mod_tile.git --depth 1 \
|
||||||
RUN ./autogen.sh \
|
&& cd mod_tile \
|
||||||
|
&& rm -rf .git \
|
||||||
|
&& ./autogen.sh \
|
||||||
&& ./configure \
|
&& ./configure \
|
||||||
&& make -j $(nproc)
|
&& make -j $(nproc) \
|
||||||
USER root
|
&& make -j $(nproc) install \
|
||||||
RUN make -j $(nproc) install \
|
|
||||||
&& make -j $(nproc) install-mod_tile \
|
&& make -j $(nproc) install-mod_tile \
|
||||||
&& ldconfig
|
&& ldconfig \
|
||||||
USER renderer
|
&& cd ..
|
||||||
|
|
||||||
# Configure stylesheet
|
# Configure stylesheet
|
||||||
WORKDIR /home/renderer/src
|
RUN mkdir -p /home/renderer/src \
|
||||||
RUN git clone https://github.com/gravitystorm/openstreetmap-carto.git
|
&& cd /home/renderer/src \
|
||||||
WORKDIR /home/renderer/src/openstreetmap-carto
|
&& git clone --single-branch --branch v5.3.1 https://github.com/gravitystorm/openstreetmap-carto.git --depth 1 \
|
||||||
USER root
|
&& cd openstreetmap-carto \
|
||||||
RUN npm install -g carto
|
&& rm -rf .git \
|
||||||
USER renderer
|
&& npm install -g carto@0.18.2 \
|
||||||
RUN carto project.mml > mapnik.xml
|
&& carto project.mml > mapnik.xml
|
||||||
|
|
||||||
# Load shapefiles
|
|
||||||
WORKDIR /home/renderer/src/openstreetmap-carto
|
|
||||||
RUN scripts/get-shapefiles.py
|
|
||||||
|
|
||||||
# Configure renderd
|
# Configure renderd
|
||||||
USER root
|
|
||||||
RUN sed -i 's/renderaccount/renderer/g' /usr/local/etc/renderd.conf \
|
RUN sed -i 's/renderaccount/renderer/g' /usr/local/etc/renderd.conf \
|
||||||
|
&& sed -i 's/\/truetype//g' /usr/local/etc/renderd.conf \
|
||||||
&& sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf
|
&& sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf
|
||||||
USER renderer
|
|
||||||
|
|
||||||
# Configure Apache
|
# Configure Apache
|
||||||
USER root
|
|
||||||
RUN mkdir /var/lib/mod_tile \
|
RUN mkdir /var/lib/mod_tile \
|
||||||
&& chown renderer /var/lib/mod_tile \
|
&& chown renderer /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 \
|
&& echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \
|
||||||
&& echo "LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so" >> /etc/apache2/conf-available/mod_headers.conf \
|
&& echo "LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so" >> /etc/apache2/conf-available/mod_headers.conf \
|
||||||
&& a2enconf mod_tile && a2enconf mod_headers
|
&& 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
|
||||||
@@ -139,14 +153,13 @@ 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
|
&& 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/
|
||||||
RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \
|
RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \
|
||||||
&& mkdir /var/log/tiles \
|
&& mkdir /var/log/tiles \
|
||||||
@@ -154,18 +167,17 @@ RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \
|
|||||||
&& ln -s /home/renderer/src/mod_tile/osmosis-db_replag /usr/bin/osmosis-db_replag \
|
&& ln -s /home/renderer/src/mod_tile/osmosis-db_replag /usr/bin/osmosis-db_replag \
|
||||||
&& echo "* * * * * renderer openstreetmap-tiles-update-expire\n" >> /etc/crontab
|
&& echo "* * * * * renderer openstreetmap-tiles-update-expire\n" >> /etc/crontab
|
||||||
|
|
||||||
# install trim_osc.py helper script
|
# Install trim_osc.py helper script
|
||||||
USER renderer
|
RUN mkdir -p /home/renderer/src \
|
||||||
RUN cd ~/src \
|
&& cd /home/renderer/src \
|
||||||
&& git clone https://github.com/zverik/regional \
|
&& git clone https://github.com/zverik/regional \
|
||||||
&& cd regional \
|
&& cd regional \
|
||||||
&& git checkout 612fe3e040d8bb70d2ab3b133f3b2cfc6c940520 \
|
&& git checkout 889d630a1e1a1bacabdd1dad6e17b49e7d58cd4b \
|
||||||
&& chmod u+x ~/src/regional/trim_osc.py
|
&& rm -rf .git \
|
||||||
|
&& chmod u+x /home/renderer/src/regional/trim_osc.py
|
||||||
|
|
||||||
# Start running
|
# Start running
|
||||||
USER root
|
|
||||||
COPY run.sh /
|
COPY run.sh /
|
||||||
COPY indexes.sql /
|
|
||||||
ENTRYPOINT ["/run.sh"]
|
ENTRYPOINT ["/run.sh"]
|
||||||
CMD []
|
CMD []
|
||||||
|
|
||||||
|
14
Makefile
14
Makefile
@@ -1,12 +1,18 @@
|
|||||||
.PHONY: build push test
|
.PHONY: build push test
|
||||||
|
|
||||||
|
DOCKER_IMAGE=overv/openstreetmap-tile-server
|
||||||
|
|
||||||
build:
|
build:
|
||||||
docker build -t overv/openstreetmap-tile-server .
|
docker build -t ${DOCKER_IMAGE} .
|
||||||
|
|
||||||
push: build
|
push: build
|
||||||
docker push overv/openstreetmap-tile-server:latest
|
docker push ${DOCKER_IMAGE}:latest
|
||||||
|
|
||||||
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 --rm -v openstreetmap-data:/var/lib/postgresql/12/main ${DOCKER_IMAGE} import
|
||||||
docker run -v openstreetmap-data:/var/lib/postgresql/10/main -p 80:80 -d overv/openstreetmap-tile-server run
|
docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main -p 8080:80 -d ${DOCKER_IMAGE} run
|
||||||
|
|
||||||
|
stop:
|
||||||
|
docker rm -f `docker ps | grep '${DOCKER_IMAGE}' | awk '{ print $$1 }'` || true
|
||||||
|
docker volume rm -f openstreetmap-data
|
||||||
|
104
README.md
104
README.md
@@ -1,6 +1,8 @@
|
|||||||
# openstreetmap-tile-server
|
# openstreetmap-tile-server
|
||||||
|
|
||||||
This container allows you to easily set up an OpenStreetMap PNG tile server given a `.osm.pbf` file. It is based on the [latest Ubuntu 18.04 LTS guide](https://switch2osm.org/manually-building-a-tile-server-18-04-lts/) from [switch2osm.org](https://switch2osm.org/) and therefore uses the default OpenStreetMap style.
|
[](https://travis-ci.org/Overv/openstreetmap-tile-server) [](https://microbadger.com/images/overv/openstreetmap-tile-server "openstreetmap-tile-server")
|
||||||
|
|
||||||
|
This container allows you to easily set up an OpenStreetMap PNG tile server given a `.osm.pbf` file. It is based on the [latest Ubuntu 18.04 LTS guide](https://switch2osm.org/serving-tiles/manually-building-a-tile-server-18-04-lts/) from [switch2osm.org](https://switch2osm.org/) and therefore uses the default OpenStreetMap style.
|
||||||
|
|
||||||
## Setting up the server
|
## Setting up the server
|
||||||
|
|
||||||
@@ -13,7 +15,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 +24,32 @@ 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.
|
||||||
|
|
||||||
|
### Letting the container download the file
|
||||||
|
|
||||||
|
It is also possible to let the container download files for you rather than mounting them in advance by using the `DOWNLOAD_PBF` and `DOWNLOAD_POLY` parameters:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run \
|
||||||
|
-e DOWNLOAD_PBF=https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf \
|
||||||
|
-e DOWNLOAD_POLY=https://download.geofabrik.de/europe/luxembourg.poly \
|
||||||
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
|
overv/openstreetmap-tile-server \
|
||||||
|
import
|
||||||
|
```
|
||||||
|
|
||||||
## Running the server
|
## Running the server
|
||||||
|
|
||||||
@@ -41,13 +57,17 @@ Run the server like this:
|
|||||||
|
|
||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-p 8080: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
|
||||||
```
|
```
|
||||||
|
|
||||||
Your tiles will now be available at `http://localhost:80/tile/{z}/{x}/{y}.png`. The demo map in `leaflet-demo.html` will then be available on `http://localhost:80`. Note that it will initially take quite a bit of time to render the larger tiles for the first time.
|
Your tiles will now be available at `http://localhost:8080/tile/{z}/{x}/{y}.png`. The demo map in `leaflet-demo.html` will then be available on `http://localhost:8080`. Note that it will initially take quite a bit of time to render the larger tiles for the first time.
|
||||||
|
|
||||||
|
### Using Docker Compose
|
||||||
|
|
||||||
|
The `docker-compose.yml` file included with this repository shows how the aforementioned command can be used with Docker Compose to run your server.
|
||||||
|
|
||||||
### Preserving rendered tiles
|
### Preserving rendered tiles
|
||||||
|
|
||||||
@@ -56,22 +76,24 @@ 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 8080: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 8080: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
|
||||||
@@ -81,13 +103,13 @@ This will enable a background process that automatically downloads changes from
|
|||||||
|
|
||||||
### Cross-origin resource sharing
|
### 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`:
|
To enable the `Access-Control-Allow-Origin` header to be able to retrieve tiles from other domains, simply set the `ALLOW_CORS` variable to `enabled`:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-p 8080:80 \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/10/main \
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
-e ALLOW_CORS=1 \
|
-e ALLOW_CORS=enabled \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
@@ -98,9 +120,9 @@ To connect to the PostgreSQL database inside the container, make sure to expose
|
|||||||
|
|
||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-p 8080:80 \
|
||||||
-p 5432:5432 \
|
-p 5432:5432 \
|
||||||
-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
|
||||||
```
|
```
|
||||||
@@ -115,10 +137,10 @@ The default password is `renderer`, but it can be changed using the `PGPASSWORD`
|
|||||||
|
|
||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-p 8080:80 \
|
||||||
-p 5432:5432 \
|
-p 5432:5432 \
|
||||||
-e PGPASSWORD=secret \
|
-e PGPASSWORD=secret \
|
||||||
-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
|
||||||
```
|
```
|
||||||
@@ -132,9 +154,21 @@ Details for update procedure and invoked scripts can be found here [link](https:
|
|||||||
The import and tile serving processes use 4 threads by default, but this number can be changed by setting the `THREADS` environment variable. For example:
|
The import and tile serving processes use 4 threads by default, but this number can be changed by setting the `THREADS` environment variable. For example:
|
||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-p 8080: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 \
|
||||||
|
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 8080:80 \
|
||||||
|
-e "OSM2PGSQL_EXTRA_ARGS=-C 4096" \
|
||||||
|
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
@@ -144,35 +178,29 @@ docker run \
|
|||||||
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:
|
||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-p 8080: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
|
### 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 \
|
||||||
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
|
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
|
||||||
-v openstreetmap-nodes:/nodes \
|
-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" \
|
-e "OSM2PGSQL_EXTRA_ARGS=--flat-nodes /nodes/flat_nodes.bin" \
|
||||||
overv/openstreetmap-tile-server \
|
overv/openstreetmap-tile-server \
|
||||||
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).
|
||||||
@@ -189,8 +217,8 @@ renderd[121]: reason: Postgis Plugin: ERROR: could not resize shared memory segm
|
|||||||
To raise it use `--shm-size` parameter. For example:
|
To raise it use `--shm-size` parameter. For example:
|
||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-p 8080: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
|
||||||
@@ -210,7 +238,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
|
|||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
14
docker-compose.yml
Normal file
14
docker-compose.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
map:
|
||||||
|
image: overv/openstreetmap-tile-server
|
||||||
|
volumes:
|
||||||
|
- openstreetmap-data:/var/lib/postgresql/12/main
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
command: "run"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
openstreetmap-data:
|
||||||
|
external: true
|
48
indexes.sql
48
indexes.sql
@@ -1,48 +0,0 @@
|
|||||||
-- Extracted from https://github.com/gravitystorm/openstreetmap-carto
|
|
||||||
-- Comes with a CC0 license
|
|
||||||
|
|
||||||
-- These are optional but suggested indexes for rendering OpenStreetMap Carto
|
|
||||||
-- with a full planet database.
|
|
||||||
-- This file is generated with scripts/indexes.py
|
|
||||||
|
|
||||||
CREATE INDEX planet_osm_roads_admin
|
|
||||||
ON planet_osm_roads USING GIST (way)
|
|
||||||
WHERE boundary = 'administrative';
|
|
||||||
CREATE INDEX planet_osm_roads_roads_ref
|
|
||||||
ON planet_osm_roads USING GIST (way)
|
|
||||||
WHERE highway IS NOT NULL AND ref IS NOT NULL;
|
|
||||||
CREATE INDEX planet_osm_roads_admin_low
|
|
||||||
ON planet_osm_roads USING GIST (way)
|
|
||||||
WHERE boundary = 'administrative' AND admin_level IN ('0', '1', '2', '3', '4');
|
|
||||||
CREATE INDEX planet_osm_line_ferry
|
|
||||||
ON planet_osm_line USING GIST (way)
|
|
||||||
WHERE route = 'ferry';
|
|
||||||
CREATE INDEX planet_osm_line_river
|
|
||||||
ON planet_osm_line USING GIST (way)
|
|
||||||
WHERE waterway = 'river';
|
|
||||||
CREATE INDEX planet_osm_line_name
|
|
||||||
ON planet_osm_line USING GIST (way)
|
|
||||||
WHERE name IS NOT NULL;
|
|
||||||
CREATE INDEX planet_osm_polygon_water
|
|
||||||
ON planet_osm_polygon USING GIST (way)
|
|
||||||
WHERE waterway IN ('dock', 'riverbank', 'canal')
|
|
||||||
OR landuse IN ('reservoir', 'basin')
|
|
||||||
OR "natural" IN ('water', 'glacier');
|
|
||||||
CREATE INDEX planet_osm_polygon_nobuilding
|
|
||||||
ON planet_osm_polygon USING GIST (way)
|
|
||||||
WHERE building IS NULL;
|
|
||||||
CREATE INDEX planet_osm_polygon_name
|
|
||||||
ON planet_osm_polygon USING GIST (way)
|
|
||||||
WHERE name IS NOT NULL;
|
|
||||||
CREATE INDEX planet_osm_polygon_way_area_z10
|
|
||||||
ON planet_osm_polygon USING GIST (way)
|
|
||||||
WHERE way_area > 23300;
|
|
||||||
CREATE INDEX planet_osm_polygon_military
|
|
||||||
ON planet_osm_polygon USING GIST (way)
|
|
||||||
WHERE (landuse = 'military' OR military = 'danger_area') AND building IS NULL;
|
|
||||||
CREATE INDEX planet_osm_polygon_way_area_z6
|
|
||||||
ON planet_osm_polygon USING GIST (way)
|
|
||||||
WHERE way_area > 5980000;
|
|
||||||
CREATE INDEX planet_osm_point_place
|
|
||||||
ON planet_osm_point USING GIST (way)
|
|
||||||
WHERE place IS NOT NULL AND name IS NOT NULL;
|
|
@@ -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 --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua --number-processes ${THREADS:-4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style ${OSM2PGSQL_EXTRA_ARGS}"
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# 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
|
||||||
@@ -111,7 +111,7 @@ if [ $# -eq 1 ] ; then
|
|||||||
m_info "Initialising Osmosis replication system to $1"
|
m_info "Initialising Osmosis replication system to $1"
|
||||||
mkdir $WORKOSM_DIR
|
mkdir $WORKOSM_DIR
|
||||||
$OSMOSIS_BIN --read-replication-interval-init workingDirectory=$WORKOSM_DIR 1>&2 2> "$OSMOSISLOG"
|
$OSMOSIS_BIN --read-replication-interval-init workingDirectory=$WORKOSM_DIR 1>&2 2> "$OSMOSISLOG"
|
||||||
wget "http://replicate-sequences.osm.mazdermind.de/?"$1"T00:00:00Z" -O $WORKOSM_DIR/state.txt
|
wget "https://replicate-sequences.osm.mazdermind.de/?"$1"T00:00:00Z" -O $WORKOSM_DIR/state.txt
|
||||||
mv $WORKOSM_DIR/configuration.txt $WORKOSM_DIR/configuration_orig.txt
|
mv $WORKOSM_DIR/configuration.txt $WORKOSM_DIR/configuration_orig.txt
|
||||||
sed "s!baseUrl=http://planet.openstreetmap.org/replication/minute!baseUrl=https://planet.openstreetmap.org/replication/minute!" $WORKOSM_DIR/configuration_orig.txt > $WORKOSM_DIR/configuration.txt
|
sed "s!baseUrl=http://planet.openstreetmap.org/replication/minute!baseUrl=https://planet.openstreetmap.org/replication/minute!" $WORKOSM_DIR/configuration_orig.txt > $WORKOSM_DIR/configuration.txt
|
||||||
else
|
else
|
||||||
|
56
run.sh
56
run.sh
@@ -3,9 +3,9 @@
|
|||||||
set -x
|
set -x
|
||||||
|
|
||||||
function createPostgresConfig() {
|
function createPostgresConfig() {
|
||||||
cp /etc/postgresql/10/main/postgresql.custom.conf.tmpl /etc/postgresql/10/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/10/main/postgresql.custom.conf
|
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/12/main/conf.d/postgresql.custom.conf
|
||||||
cat /etc/postgresql/10/main/postgresql.custom.conf
|
cat /etc/postgresql/12/main/conf.d/postgresql.custom.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPostgresPassword() {
|
function setPostgresPassword() {
|
||||||
@@ -24,6 +24,12 @@ if [ "$#" -ne 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = "import" ]; then
|
if [ "$1" = "import" ]; then
|
||||||
|
# Ensure that database directory is in right state
|
||||||
|
chown postgres:postgres -R /var/lib/postgresql
|
||||||
|
if [ ! -f /var/lib/postgresql/12/main/PG_VERSION ]; then
|
||||||
|
sudo -u postgres /usr/lib/postgresql/12/bin/pg_ctl -D /var/lib/postgresql/12/main/ initdb -o "--locale C.UTF-8"
|
||||||
|
fi
|
||||||
|
|
||||||
# Initialize PostgreSQL
|
# Initialize PostgreSQL
|
||||||
createPostgresConfig
|
createPostgresConfig
|
||||||
service postgresql start
|
service postgresql start
|
||||||
@@ -36,12 +42,22 @@ if [ "$1" = "import" ]; then
|
|||||||
setPostgresPassword
|
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 ] && [ -z "$DOWNLOAD_PBF" ]; then
|
||||||
echo "WARNING: No import file at /data.osm.pbf, so importing Luxembourg as example..."
|
echo "WARNING: No import file at /data.osm.pbf, so importing Luxembourg as example..."
|
||||||
wget -nv http://download.geofabrik.de/europe/luxembourg-latest.osm.pbf -O /data.osm.pbf
|
DOWNLOAD_PBF="https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf"
|
||||||
wget -nv http://download.geofabrik.de/europe/luxembourg.poly -O /data.poly
|
DOWNLOAD_POLY="https://download.geofabrik.de/europe/luxembourg.poly"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$DOWNLOAD_PBF" ]; then
|
||||||
|
echo "INFO: Download PBF file: $DOWNLOAD_PBF"
|
||||||
|
wget "$WGET_ARGS" "$DOWNLOAD_PBF" -O /data.osm.pbf
|
||||||
|
if [ -n "$DOWNLOAD_POLY" ]; then
|
||||||
|
echo "INFO: Download PBF-POLY file: $DOWNLOAD_POLY"
|
||||||
|
wget "$WGET_ARGS" "$DOWNLOAD_POLY" -O /data.poly
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$UPDATES" = "enabled" ]; then
|
||||||
# determine and set osmosis_replication_timestamp (for consecutive updates)
|
# 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 > /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
|
osmium fileinfo /data.osm.pbf | grep 'osmosis_replication_timestamp=' | cut -b35-44 > /var/lib/mod_tile/replication_timestamp.txt
|
||||||
@@ -49,6 +65,7 @@ if [ "$1" = "import" ]; then
|
|||||||
|
|
||||||
# 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
|
||||||
@@ -56,10 +73,17 @@ 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} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style /data.osm.pbf ${OSM2PGSQL_EXTRA_ARGS}
|
||||||
|
|
||||||
# Create indexes
|
# Create indexes
|
||||||
sudo -u postgres psql -d gis -f indexes.sql
|
sudo -u postgres psql -d gis -f /home/renderer/src/openstreetmap-carto/indexes.sql
|
||||||
|
|
||||||
|
#Import external data
|
||||||
|
sudo chown -R renderer: /home/renderer/src
|
||||||
|
sudo -u renderer python3 /home/renderer/src/openstreetmap-carto/scripts/get-external-data.py -c /home/renderer/src/openstreetmap-carto/external-data.yml -D /home/renderer/src/openstreetmap-carto/data
|
||||||
|
|
||||||
|
# Register that data has changed for mod_tile caching purposes
|
||||||
|
touch /var/lib/mod_tile/planet-import-complete
|
||||||
|
|
||||||
service postgresql stop
|
service postgresql stop
|
||||||
|
|
||||||
@@ -74,7 +98,7 @@ if [ "$1" = "run" ]; then
|
|||||||
chown postgres:postgres /var/lib/postgresql -R
|
chown postgres:postgres /var/lib/postgresql -R
|
||||||
|
|
||||||
# Configure Apache CORS
|
# Configure Apache CORS
|
||||||
if [ "$ALLOW_CORS" == "1" ]; then
|
if [ "$ALLOW_CORS" == "enabled" ] || [ "$ALLOW_CORS" == "1" ]; then
|
||||||
echo "export APACHE_ARGUMENTS='-D ALLOW_CORS'" >> /etc/apache2/envvars
|
echo "export APACHE_ARGUMENTS='-D ALLOW_CORS'" >> /etc/apache2/envvars
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -88,12 +112,20 @@ if [ "$1" = "run" ]; then
|
|||||||
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
|
||||||
|
|
||||||
# start cron job to trigger consecutive updates
|
# start cron job to trigger consecutive updates
|
||||||
if [ "$UPDATES" = "enabled" ]; then
|
if [ "$UPDATES" = "enabled" ] || [ "$UPDATES" = "1" ]; 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