Compare commits
15 Commits
v1.7.3
...
issue-264-
Author | SHA1 | Date | |
---|---|---|---|
|
704480754d | ||
|
30fb985a66 | ||
|
cffbd7be5b | ||
|
d0673dc72d | ||
|
ef7ba04540 | ||
|
522f66437c | ||
|
0f229a0cbd | ||
|
f1203714c1 | ||
|
e6e8c2d427 | ||
|
672e2cd5b3 | ||
|
a1cbf0d74c | ||
|
705237446a | ||
|
1e684edb6a | ||
|
4b93ca3e52 | ||
|
0a4d079b08 |
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/.github/
|
||||||
|
/.travis.yml
|
||||||
|
/docker-compose.yml
|
||||||
|
/LICENSE
|
||||||
|
/Makefile
|
||||||
|
/README.md
|
166
.github/workflows/build-and-test.yaml
vendored
Normal file
166
.github/workflows/build-and-test.yaml
vendored
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
name: Build and test image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
# cancel outdated jobs for the same reference
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE : ${{ github.repository_owner }}/openstreetmap-tile-server
|
||||||
|
TAG : ${{ github.sha }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
VOLUME : osm-db
|
||||||
|
CONTAINER : osm-www
|
||||||
|
MOUNT : /data/database/
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
-
|
||||||
|
name: Environment
|
||||||
|
run : |
|
||||||
|
echo IMAGE=$(echo ${{ env.IMAGE }} | tr '[:upper:]' '[:lower:]') >>$GITHUB_ENV
|
||||||
|
-
|
||||||
|
name: Docker build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
pull : true
|
||||||
|
load : true
|
||||||
|
context : .
|
||||||
|
file : ./Dockerfile
|
||||||
|
tags : ${{env.IMAGE}}:${{env.TAG}}
|
||||||
|
cache-from : type=gha,scope=${{ github.workflow }}
|
||||||
|
cache-to : type=gha,scope=${{ github.workflow }},mode=max
|
||||||
|
-
|
||||||
|
name: Import Luxembourg
|
||||||
|
run : |
|
||||||
|
docker volume create ${VOLUME}
|
||||||
|
docker run --rm --shm-size=128M -v ${VOLUME}:${MOUNT} -e UPDATES=enabled ${IMAGE}:${TAG} import
|
||||||
|
-
|
||||||
|
name: Start server
|
||||||
|
run : |
|
||||||
|
docker run --rm --shm-size=128M -v ${VOLUME}:${MOUNT} -e UPDATES=enabled -p 80:80 -d --name ${CONTAINER} ${IMAGE}:${TAG} run
|
||||||
|
sleep 30
|
||||||
|
-
|
||||||
|
name: Download tiles
|
||||||
|
run : |
|
||||||
|
curl http://localhost/tile/0/0/0.png --fail -o 000.png
|
||||||
|
curl http://localhost/tile/1/0/0.png --fail -o 100.png
|
||||||
|
curl http://localhost/tile/1/0/1.png --fail -o 101.png
|
||||||
|
curl http://localhost/tile/1/1/0.png --fail -o 110.png
|
||||||
|
curl http://localhost/tile/1/1/1.png --fail -o 111.png
|
||||||
|
curl http://localhost/tile/18/138474/85459.png --fail -o empty.png
|
||||||
|
curl http://localhost/tile/18/135536/89345.png --fail -o example.png
|
||||||
|
-
|
||||||
|
name: Upload tiles
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: tiles
|
||||||
|
path: '*.png'
|
||||||
|
-
|
||||||
|
name: Verify tiles
|
||||||
|
run : |
|
||||||
|
sha1sum *.png
|
||||||
|
sha1sum --check <<EOF
|
||||||
|
c226ca747874fb1307eef853feaf9d8db28cef2b *empty.png
|
||||||
|
EOF
|
||||||
|
tiles=(`ls *.png`)
|
||||||
|
for ((i=0; i<${#tiles[@]}; i++)) ; do
|
||||||
|
if [ `file --brief --mime-type "${tiles[$i]}"` != 'image/png' ] ; then
|
||||||
|
>&2 echo "ERROR: ${tiles[$i]} is not a image/png file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
for ((j=i+1; j<${#tiles[@]}; j++)) ; do
|
||||||
|
if ( diff "${tiles[$i]}" "${tiles[$j]}" ) ; then
|
||||||
|
>&2 echo "ERROR: ${tiles[$i]} is identical to ${tiles[$j]}"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
-
|
||||||
|
name: Cleanup
|
||||||
|
run : |
|
||||||
|
docker rm --force --volumes ${CONTAINER}
|
||||||
|
docker volume rm --force ${VOLUME}
|
||||||
|
docker rmi --force ${IMAGE}:${TAG}
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- test
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Environment
|
||||||
|
run : |
|
||||||
|
echo IMAGE=$(echo ${{ env.IMAGE }} | tr '[:upper:]' '[:lower:]') >>$GITHUB_ENV
|
||||||
|
echo DOCKERHUB_IMAGE=$([ "${{ secrets.DOCKERHUB_USERNAME }}" != '' ] && [ "${{ secrets.DOCKERHUB_PASSWORD }}" != "" ] && echo "$IMAGE") >>$GITHUB_ENV
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v3
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ env.DOCKERHUB_IMAGE }}
|
||||||
|
ghcr.io/${{ env.IMAGE }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
-
|
||||||
|
name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
if: ${{ env.DOCKERHUB_IMAGE != '' }}
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
|
-
|
||||||
|
name: Login to GHCR
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry : ghcr.io
|
||||||
|
username : ${{ github.repository_owner }}
|
||||||
|
password : ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
pull : true
|
||||||
|
push : true
|
||||||
|
context : .
|
||||||
|
file : ./Dockerfile
|
||||||
|
tags : ${{ steps.meta.outputs.tags }}
|
||||||
|
labels : ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from : type=gha,scope=${{ github.workflow }}
|
||||||
|
cache-to : type=gha,scope=${{ github.workflow }},mode=max
|
@@ -7,12 +7,13 @@ services:
|
|||||||
before_install:
|
before_install:
|
||||||
- echo "Before install"
|
- echo "Before install"
|
||||||
before_script:
|
before_script:
|
||||||
|
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||||
- docker pull overv/openstreetmap-tile-server || true
|
- docker pull overv/openstreetmap-tile-server || true
|
||||||
script:
|
script:
|
||||||
- docker build --pull --cache-from overv/openstreetmap-tile-server --tag overv/openstreetmap-tile-server .
|
- docker build --pull --cache-from overv/openstreetmap-tile-server --tag overv/openstreetmap-tile-server .
|
||||||
- docker volume create openstreetmap-data
|
- docker volume create osm-data
|
||||||
- docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main overv/openstreetmap-tile-server import
|
- docker run --rm -v osm-data:/data/database/ 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
|
- docker run --rm -v osm-data:/data/database/ -p 8080:80 -d overv/openstreetmap-tile-server run
|
||||||
- sleep 30
|
- sleep 30
|
||||||
- make DOCKER_IMAGE=overv/openstreetmap-tile-server stop
|
- make DOCKER_IMAGE=overv/openstreetmap-tile-server stop
|
||||||
after_script:
|
after_script:
|
||||||
@@ -21,7 +22,6 @@ after_success:
|
|||||||
- if [[ "$TRAVIS_BRANCH" == "master" ]];
|
- if [[ "$TRAVIS_BRANCH" == "master" ]];
|
||||||
then
|
then
|
||||||
docker images ;
|
docker images ;
|
||||||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ;
|
|
||||||
docker push overv/openstreetmap-tile-server ;
|
docker push overv/openstreetmap-tile-server ;
|
||||||
fi
|
fi
|
||||||
notifications:
|
notifications:
|
||||||
|
313
Dockerfile
313
Dockerfile
@@ -1,67 +1,127 @@
|
|||||||
FROM ubuntu:20.04
|
FROM ubuntu:20.04 AS compiler-common
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
git-core \
|
||||||
|
checkinstall \
|
||||||
|
g++ \
|
||||||
|
gnupg2 \
|
||||||
|
make \
|
||||||
|
tar \
|
||||||
|
wget \
|
||||||
|
ca-certificates \
|
||||||
|
&& apt-get update
|
||||||
|
|
||||||
|
###########################################################################################################
|
||||||
|
|
||||||
|
FROM compiler-common AS compiler-postgis
|
||||||
|
RUN echo "deb http://apt.postgresql.org/pub/repos/apt focal-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
|
||||||
|
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
postgresql-server-dev-14 \
|
||||||
|
libxml2-dev \
|
||||||
|
libgeos-dev \
|
||||||
|
libproj-dev \
|
||||||
|
&& wget https://download.osgeo.org/postgis/source/postgis-3.2.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 --without-protobuf --without-raster \
|
||||||
|
&& make -j $(nproc) \
|
||||||
|
&& checkinstall --pkgversion="3.2.1" --install=no --default make install
|
||||||
|
|
||||||
|
###########################################################################################################
|
||||||
|
|
||||||
|
FROM compiler-common AS compiler-osm2pgsql
|
||||||
|
RUN apt-get install -y --no-install-recommends \
|
||||||
|
cmake \
|
||||||
|
libboost-dev \
|
||||||
|
libboost-system-dev \
|
||||||
|
libboost-filesystem-dev \
|
||||||
|
libexpat1-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
libbz2-dev \
|
||||||
|
libpq-dev \
|
||||||
|
libproj-dev \
|
||||||
|
lua5.3 \
|
||||||
|
liblua5.3-dev \
|
||||||
|
pandoc
|
||||||
|
RUN cd ~ \
|
||||||
|
&& git clone -b master --single-branch https://github.com/openstreetmap/osm2pgsql.git --depth 1 \
|
||||||
|
&& cd osm2pgsql \
|
||||||
|
&& mkdir build \
|
||||||
|
&& cd build \
|
||||||
|
&& cmake .. \
|
||||||
|
&& make -j $(nproc) \
|
||||||
|
&& checkinstall --pkgversion="1" --install=no --default make install
|
||||||
|
|
||||||
|
###########################################################################################################
|
||||||
|
|
||||||
|
FROM compiler-common AS compiler-modtile-renderd
|
||||||
|
RUN apt-get install -y --no-install-recommends \
|
||||||
|
apache2-dev \
|
||||||
|
automake \
|
||||||
|
autoconf \
|
||||||
|
autotools-dev \
|
||||||
|
libtool \
|
||||||
|
libmapnik-dev
|
||||||
|
RUN cd ~ \
|
||||||
|
&& git clone -b switch2osm --single-branch https://github.com/SomeoneElseOSM/mod_tile.git --depth 1 \
|
||||||
|
&& cd mod_tile \
|
||||||
|
&& ./autogen.sh \
|
||||||
|
&& ./configure \
|
||||||
|
&& make -j $(nproc) \
|
||||||
|
&& checkinstall --pkgversion="1" --install=no --pkgname "renderd" --default make install \
|
||||||
|
&& checkinstall --pkgversion="1" --install=no --pkgname "mod_tile" --default make install-mod_tile
|
||||||
|
|
||||||
|
###########################################################################################################
|
||||||
|
|
||||||
|
FROM compiler-common AS compiler-stylesheet
|
||||||
|
RUN cd ~ \
|
||||||
|
&& git clone --single-branch --branch v5.4.0 https://github.com/gravitystorm/openstreetmap-carto.git --depth 1 \
|
||||||
|
&& cd openstreetmap-carto \
|
||||||
|
&& rm -rf .git
|
||||||
|
|
||||||
|
###########################################################################################################
|
||||||
|
|
||||||
|
FROM compiler-common AS compiler-helper-script
|
||||||
|
RUN mkdir -p /home/renderer/src \
|
||||||
|
&& cd /home/renderer/src \
|
||||||
|
&& git clone https://github.com/zverik/regional \
|
||||||
|
&& cd regional \
|
||||||
|
&& rm -rf .git \
|
||||||
|
&& chmod u+x /home/renderer/src/regional/trim_osc.py
|
||||||
|
|
||||||
|
###########################################################################################################
|
||||||
|
|
||||||
|
FROM ubuntu:20.04 AS final
|
||||||
|
|
||||||
# Based on
|
# Based on
|
||||||
# https://switch2osm.org/serving-tiles/manually-building-a-tile-server-18-04-lts/
|
# https://switch2osm.org/serving-tiles/manually-building-a-tile-server-18-04-lts/
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
# Set up environment
|
|
||||||
ENV TZ=UTC
|
|
||||||
ENV AUTOVACUUM=on
|
ENV AUTOVACUUM=on
|
||||||
ENV UPDATES=disabled
|
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
|
# Get packages
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y wget gnupg2 lsb-core apt-transport-https ca-certificates curl \
|
&& apt-get install -y --no-install-recommends \
|
||||||
&& 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 install -y nodejs
|
|
||||||
|
|
||||||
RUN apt-get install -y --no-install-recommends \
|
|
||||||
apache2 \
|
apache2 \
|
||||||
apache2-dev \
|
|
||||||
autoconf \
|
|
||||||
build-essential \
|
|
||||||
bzip2 \
|
|
||||||
cmake \
|
|
||||||
cron \
|
cron \
|
||||||
fonts-noto-cjk \
|
fonts-noto-cjk \
|
||||||
fonts-noto-hinted \
|
fonts-noto-hinted \
|
||||||
fonts-noto-unhinted \
|
fonts-noto-unhinted \
|
||||||
gcc \
|
gnupg2 \
|
||||||
gdal-bin \
|
gdal-bin \
|
||||||
git-core \
|
|
||||||
libagg-dev \
|
|
||||||
libboost-filesystem-dev \
|
|
||||||
libboost-system-dev \
|
|
||||||
libbz2-dev \
|
|
||||||
libcairo-dev \
|
|
||||||
libcairomm-1.0-dev \
|
|
||||||
libexpat1-dev \
|
|
||||||
libfreetype6-dev \
|
|
||||||
libgdal-dev \
|
|
||||||
libgeos++-dev \
|
|
||||||
libgeos-dev \
|
|
||||||
libicu-dev \
|
|
||||||
liblua5.3-dev \
|
liblua5.3-dev \
|
||||||
libmapnik-dev \
|
|
||||||
libpq-dev \
|
|
||||||
libproj-dev \
|
|
||||||
libprotobuf-c-dev \
|
|
||||||
libtiff5-dev \
|
|
||||||
libtool \
|
|
||||||
libxml2-dev \
|
|
||||||
lua5.3 \
|
lua5.3 \
|
||||||
make \
|
|
||||||
mapnik-utils \
|
mapnik-utils \
|
||||||
|
npm \
|
||||||
osmium-tool \
|
osmium-tool \
|
||||||
osmosis \
|
osmosis \
|
||||||
postgis \
|
|
||||||
postgresql-12 \
|
|
||||||
postgresql-contrib-12 \
|
|
||||||
postgresql-server-dev-12 \
|
|
||||||
protobuf-c-compiler \
|
|
||||||
python-is-python3 \
|
python-is-python3 \
|
||||||
python3-mapnik \
|
python3-mapnik \
|
||||||
python3-lxml \
|
python3-lxml \
|
||||||
@@ -69,116 +129,101 @@ RUN apt-get install -y --no-install-recommends \
|
|||||||
python3-shapely \
|
python3-shapely \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
sudo \
|
sudo \
|
||||||
tar \
|
|
||||||
ttf-unifont \
|
ttf-unifont \
|
||||||
unzip \
|
|
||||||
wget \
|
wget \
|
||||||
zlib1g-dev \
|
&& echo "deb http://apt.postgresql.org/pub/repos/apt focal-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
|
||||||
|
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends postgresql-14 \
|
||||||
&& 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
|
|
||||||
RUN adduser --disabled-password --gecos "" renderer
|
RUN adduser --disabled-password --gecos "" renderer
|
||||||
|
|
||||||
# Install latest osm2pgsql
|
# Install python libraries
|
||||||
RUN mkdir -p /home/renderer/src \
|
RUN pip3 install \
|
||||||
&& cd /home/renderer/src \
|
requests \
|
||||||
&& git clone -b master https://github.com/openstreetmap/osm2pgsql.git --depth 1 \
|
osmium \
|
||||||
&& cd /home/renderer/src/osm2pgsql \
|
pyyaml
|
||||||
&& rm -rf .git \
|
|
||||||
&& mkdir build \
|
|
||||||
&& cd build \
|
|
||||||
&& cmake .. \
|
|
||||||
&& make -j $(nproc) \
|
|
||||||
&& make -j $(nproc) install \
|
|
||||||
&& mkdir /nodes \
|
|
||||||
&& chown renderer:renderer /nodes \
|
|
||||||
&& rm -rf /home/renderer/src/osm2pgsql
|
|
||||||
|
|
||||||
# Install mod_tile and renderd
|
# Install carto for stylesheet
|
||||||
RUN mkdir -p /home/renderer/src \
|
RUN npm install -g carto@0.18.2
|
||||||
&& cd /home/renderer/src \
|
|
||||||
&& git clone -b switch2osm https://github.com/SomeoneElseOSM/mod_tile.git --depth 1 \
|
|
||||||
&& cd mod_tile \
|
|
||||||
&& rm -rf .git \
|
|
||||||
&& ./autogen.sh \
|
|
||||||
&& ./configure \
|
|
||||||
&& make -j $(nproc) \
|
|
||||||
&& make -j $(nproc) install \
|
|
||||||
&& make -j $(nproc) install-mod_tile \
|
|
||||||
&& ldconfig \
|
|
||||||
&& cd ..
|
|
||||||
|
|
||||||
# Configure stylesheet
|
|
||||||
RUN mkdir -p /home/renderer/src \
|
|
||||||
&& cd /home/renderer/src \
|
|
||||||
&& git clone --single-branch --branch v5.3.1 https://github.com/gravitystorm/openstreetmap-carto.git --depth 1 \
|
|
||||||
&& cd openstreetmap-carto \
|
|
||||||
&& rm -rf .git \
|
|
||||||
&& npm install -g carto@0.18.2 \
|
|
||||||
&& carto project.mml > mapnik.xml
|
|
||||||
|
|
||||||
# Configure renderd
|
|
||||||
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
|
|
||||||
|
|
||||||
# Configure Apache
|
# Configure Apache
|
||||||
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 \
|
||||||
&& 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
|
||||||
COPY leaflet-demo.html /var/www/html/index.html
|
COPY leaflet-demo.html /var/www/html/index.html
|
||||||
RUN ln -sf /dev/stdout /var/log/apache2/access.log \
|
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
|
|
||||||
COPY postgresql.custom.conf.tmpl /etc/postgresql/12/main/
|
|
||||||
RUN chown -R postgres:postgres /var/lib/postgresql \
|
|
||||||
&& chown postgres:postgres /etc/postgresql/12/main/postgresql.custom.conf.tmpl \
|
|
||||||
&& 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.sh /usr/bin/
|
||||||
RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \
|
RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire.sh \
|
||||||
&& mkdir /var/log/tiles \
|
&& mkdir /var/log/tiles \
|
||||||
&& chmod a+rw /var/log/tiles \
|
&& chmod a+rw /var/log/tiles \
|
||||||
&& 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.sh\n" >> /etc/crontab
|
||||||
|
|
||||||
# Install trim_osc.py helper script
|
# Configure PosgtreSQL
|
||||||
RUN mkdir -p /home/renderer/src \
|
COPY postgresql.custom.conf.tmpl /etc/postgresql/14/main/
|
||||||
&& cd /home/renderer/src \
|
RUN chown -R postgres:postgres /var/lib/postgresql \
|
||||||
&& git clone https://github.com/zverik/regional \
|
&& chown postgres:postgres /etc/postgresql/14/main/postgresql.custom.conf.tmpl \
|
||||||
&& cd regional \
|
&& echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/14/main/pg_hba.conf \
|
||||||
&& git checkout 889d630a1e1a1bacabdd1dad6e17b49e7d58cd4b \
|
&& echo "host all all ::/0 md5" >> /etc/postgresql/14/main/pg_hba.conf
|
||||||
&& rm -rf .git \
|
|
||||||
&& chmod u+x /home/renderer/src/regional/trim_osc.py
|
# Create volume directories
|
||||||
|
RUN mkdir -p /data/database/ \
|
||||||
|
&& mkdir -p /data/style/ \
|
||||||
|
&& mkdir -p /home/renderer/src/ \
|
||||||
|
&& chown -R renderer: /data/ \
|
||||||
|
&& chown -R renderer: /home/renderer/src/ \
|
||||||
|
&& mv /var/lib/postgresql/14/main/ /data/database/postgres/ \
|
||||||
|
&& mv /var/lib/mod_tile/ /data/tiles/ \
|
||||||
|
&& ln -s /data/database/postgres /var/lib/postgresql/14/main \
|
||||||
|
&& ln -s /data/style /home/renderer/src/openstreetmap-carto \
|
||||||
|
&& ln -s /data/tiles /var/lib/mod_tile \
|
||||||
|
;
|
||||||
|
|
||||||
|
# Install PostGIS
|
||||||
|
COPY --from=compiler-postgis postgis_src/postgis-src_3.2.1-1_amd64.deb .
|
||||||
|
RUN dpkg -i postgis-src_3.2.1-1_amd64.deb \
|
||||||
|
&& rm postgis-src_3.2.1-1_amd64.deb
|
||||||
|
|
||||||
|
# Install osm2pgsql
|
||||||
|
COPY --from=compiler-osm2pgsql /root/osm2pgsql/build/build_1-1_amd64.deb .
|
||||||
|
RUN dpkg -i build_1-1_amd64.deb \
|
||||||
|
&& rm build_1-1_amd64.deb
|
||||||
|
|
||||||
|
# Install renderd
|
||||||
|
COPY --from=compiler-modtile-renderd /root/mod_tile/renderd_1-1_amd64.deb .
|
||||||
|
RUN dpkg -i renderd_1-1_amd64.deb \
|
||||||
|
&& rm renderd_1-1_amd64.deb \
|
||||||
|
&& 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
|
||||||
|
|
||||||
|
# Install mod_tile
|
||||||
|
COPY --from=compiler-modtile-renderd /root/mod_tile/mod-tile_1-1_amd64.deb .
|
||||||
|
RUN dpkg -i mod-tile_1-1_amd64.deb \
|
||||||
|
&& ldconfig \
|
||||||
|
&& rm mod-tile_1-1_amd64.deb
|
||||||
|
|
||||||
|
COPY --from=compiler-modtile-renderd /root/mod_tile/osmosis-db_replag /usr/bin/osmosis-db_replag
|
||||||
|
|
||||||
|
# Install helper script
|
||||||
|
COPY --from=compiler-helper-script /home/renderer/src/regional /home/renderer/src/regional
|
||||||
|
|
||||||
|
COPY --from=compiler-stylesheet /root/openstreetmap-carto /home/renderer/src/openstreetmap-carto-backup
|
||||||
|
|
||||||
# Start running
|
# Start running
|
||||||
COPY run.sh /
|
COPY run.sh /
|
||||||
ENTRYPOINT ["/run.sh"]
|
ENTRYPOINT ["/run.sh"]
|
||||||
CMD []
|
CMD []
|
||||||
|
|
||||||
EXPOSE 80 5432
|
EXPOSE 80 5432
|
||||||
|
201
LICENSE
Normal file
201
LICENSE
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright 2019 Alexander Overvoorde
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
8
Makefile
8
Makefile
@@ -9,10 +9,10 @@ push: build
|
|||||||
docker push ${DOCKER_IMAGE}:latest
|
docker push ${DOCKER_IMAGE}:latest
|
||||||
|
|
||||||
test: build
|
test: build
|
||||||
docker volume create openstreetmap-data
|
docker volume create osm-data
|
||||||
docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main ${DOCKER_IMAGE} import
|
docker run --rm -v osm-data:/data/database/ ${DOCKER_IMAGE} import
|
||||||
docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main -p 8080:80 -d ${DOCKER_IMAGE} run
|
docker run --rm -v osm-data:/data/database/ -p 8080:80 -d ${DOCKER_IMAGE} run
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
docker rm -f `docker ps | grep '${DOCKER_IMAGE}' | awk '{ print $$1 }'` || true
|
docker rm -f `docker ps | grep '${DOCKER_IMAGE}' | awk '{ print $$1 }'` || true
|
||||||
docker volume rm -f openstreetmap-data
|
docker volume rm -f osm-data
|
||||||
|
93
README.md
93
README.md
@@ -1,6 +1,7 @@
|
|||||||
# openstreetmap-tile-server
|
# openstreetmap-tile-server
|
||||||
|
|
||||||
[](https://travis-ci.org/Overv/openstreetmap-tile-server) [](https://microbadger.com/images/overv/openstreetmap-tile-server "openstreetmap-tile-server")
|
[](https://travis-ci.org/Overv/openstreetmap-tile-server) [](https://microbadger.com/images/overv/openstreetmap-tile-server "openstreetmap-tile-server")
|
||||||
|
[](https://hub.docker.com/r/overv/openstreetmap-tile-server/tags)
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
@@ -8,36 +9,43 @@ This container allows you to easily set up an OpenStreetMap PNG tile server give
|
|||||||
|
|
||||||
First create a Docker volume to hold the PostgreSQL database that will contain the OpenStreetMap data:
|
First create a Docker volume to hold the PostgreSQL database that will contain the OpenStreetMap data:
|
||||||
|
|
||||||
docker volume create openstreetmap-data
|
docker volume create osm-data
|
||||||
|
|
||||||
Next, download an .osm.pbf extract from geofabrik.de for the region that you're interested in. You can then start importing it into PostgreSQL by running a container and mounting the file as `/data.osm.pbf`. For example:
|
Next, download an `.osm.pbf` extract from geofabrik.de for the region that you're interested in. You can then start importing it into PostgreSQL by running a container and mounting the file as `/data/region.osm.pbf`. For example:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
|
-v /absolute/path/to/luxembourg.osm.pbf:/data/region.osm.pbf \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
overv/openstreetmap-tile-server \
|
overv/openstreetmap-tile-server \
|
||||||
import
|
import
|
||||||
```
|
```
|
||||||
|
|
||||||
If the container exits without errors, then your data has been successfully imported and you are now ready to run the tile server.
|
If the container exits without errors, then your data has been successfully imported and you are now ready to run the tile server.
|
||||||
|
|
||||||
|
Note that the import process requires an internet connection. The run process does not require an internet connection. If you want to run the openstreetmap-tile server on a computer that is isolated, you must first import on an internet connected computer, export the `osm-data` volume as a tarfile, and then restore the data volume on the target computer system.
|
||||||
|
|
||||||
|
Also when running on an isolated system, the default `index.html` from the container will not work, as it requires access to the web for the leaflet packages.
|
||||||
|
|
||||||
### 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, and also include the `UPDATES=enabled` variable:
|
If your import is an extract of the planet and has polygonal bounds associated with it, like those from [geofabrik.de](https://download.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 \
|
-e UPDATES=enabled \
|
||||||
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
|
-v /absolute/path/to/luxembourg.osm.pbf:/data/region.osm.pbf \
|
||||||
-v /absolute/path/to/luxembourg.poly:/data.poly \
|
-v /absolute/path/to/luxembourg.poly:/data/region.poly \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
overv/openstreetmap-tile-server \
|
overv/openstreetmap-tile-server \
|
||||||
import
|
import
|
||||||
```
|
```
|
||||||
|
|
||||||
Refer to the section *Automatic updating and tile expiry* to actually enable the updates while running the tile server.
|
Refer to the section *Automatic updating and tile expiry* to actually enable the updates while running the tile server.
|
||||||
|
|
||||||
|
Please note: If you're not importing the whole planet, then the `.poly` file is necessary to limit automatic updates to the relevant region.
|
||||||
|
Therefore, when you only have a `.osm.pbf` file but not a `.poly` file, you should not enable automatic updates.
|
||||||
|
|
||||||
### Letting the container download the file
|
### 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:
|
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:
|
||||||
@@ -46,11 +54,37 @@ It is also possible to let the container download files for you rather than moun
|
|||||||
docker run \
|
docker run \
|
||||||
-e DOWNLOAD_PBF=https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf \
|
-e DOWNLOAD_PBF=https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf \
|
||||||
-e DOWNLOAD_POLY=https://download.geofabrik.de/europe/luxembourg.poly \
|
-e DOWNLOAD_POLY=https://download.geofabrik.de/europe/luxembourg.poly \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
overv/openstreetmap-tile-server \
|
overv/openstreetmap-tile-server \
|
||||||
import
|
import
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Using an alternate style
|
||||||
|
|
||||||
|
By default the container will use openstreetmap-carto if it is not specified. However, you can modify the style at run-time. Be aware you need the style mounted at `run` AND `import` as the Lua script needs to be run:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run \
|
||||||
|
-e DOWNLOAD_PBF=https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf \
|
||||||
|
-e DOWNLOAD_POLY=https://download.geofabrik.de/europe/luxembourg.poly \
|
||||||
|
-e NAME_LUA=sample.lua
|
||||||
|
-e NAME_STYLE=test.style
|
||||||
|
-e NAME_MML=project.mml
|
||||||
|
-e NAME_SQL=test.sql
|
||||||
|
-v /home/user/openstreetmap-carto-modified:/data/style/ \
|
||||||
|
-v osm-data:/data/database/ \
|
||||||
|
overv/openstreetmap-tile-server \
|
||||||
|
import
|
||||||
|
```
|
||||||
|
|
||||||
|
If you do not define the "NAME_*" variables, the script will default to those found in the openstreetmap-carto style.
|
||||||
|
|
||||||
|
Be sure to mount the volume during `run` with the same `-v /home/user/openstreetmap-carto-modified:/data/style/`
|
||||||
|
|
||||||
|
If you do not see the expected style upon `run` double check your paths as the style may not have been found at the directory specified. By default, `openstreetmap-carto` will be used if a style cannot be found
|
||||||
|
|
||||||
|
**Only openstreetmap-carto and styles like it, eg, ones with one lua script, one style, one mml, one SQL can be used**
|
||||||
|
|
||||||
## Running the server
|
## Running the server
|
||||||
|
|
||||||
Run the server like this:
|
Run the server like this:
|
||||||
@@ -58,7 +92,7 @@ Run the server like this:
|
|||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 8080:80 \
|
-p 8080:80 \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
@@ -71,19 +105,19 @@ The `docker-compose.yml` file included with this repository shows how the aforem
|
|||||||
|
|
||||||
### Preserving rendered tiles
|
### Preserving rendered tiles
|
||||||
|
|
||||||
Tiles that have already been rendered will be stored in `/var/lib/mod_tile`. To make sure that this data survives container restarts, you should create another volume for it:
|
Tiles that have already been rendered will be stored in `/data/tiles/`. To make sure that this data survives container restarts, you should create another volume for it:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker volume create openstreetmap-rendered-tiles
|
docker volume create osm-tiles
|
||||||
docker run \
|
docker run \
|
||||||
-p 8080:80 \
|
-p 8080:80 \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
-v openstreetmap-rendered-tiles:/var/lib/mod_tile \
|
-v osm-tiles:/data/tiles/ \
|
||||||
-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!**
|
**If you do this, then make sure to also run the import with the `osm-tiles` volume to make sure that caching works properly across updates!**
|
||||||
|
|
||||||
### Enabling automatic updating (optional)
|
### Enabling automatic updating (optional)
|
||||||
|
|
||||||
@@ -93,8 +127,8 @@ Given that you've set up your import as described in the *Automatic updates* sec
|
|||||||
docker run \
|
docker run \
|
||||||
-p 8080:80 \
|
-p 8080:80 \
|
||||||
-e UPDATES=enabled \
|
-e UPDATES=enabled \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
-v openstreetmap-rendered-tiles:/var/lib/mod_tile \
|
-v osm-tiles:/data/tiles/ \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
@@ -108,7 +142,7 @@ To enable the `Access-Control-Allow-Origin` header to be able to retrieve tiles
|
|||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 8080:80 \
|
-p 8080:80 \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
-e ALLOW_CORS=enabled \
|
-e ALLOW_CORS=enabled \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
@@ -122,7 +156,7 @@ To connect to the PostgreSQL database inside the container, make sure to expose
|
|||||||
docker run \
|
docker run \
|
||||||
-p 8080:80 \
|
-p 8080:80 \
|
||||||
-p 5432:5432 \
|
-p 5432:5432 \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
@@ -140,7 +174,7 @@ docker run \
|
|||||||
-p 8080:80 \
|
-p 8080:80 \
|
||||||
-p 5432:5432 \
|
-p 5432:5432 \
|
||||||
-e PGPASSWORD=secret \
|
-e PGPASSWORD=secret \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
@@ -156,7 +190,7 @@ The import and tile serving processes use 4 threads by default, but this number
|
|||||||
docker run \
|
docker run \
|
||||||
-p 8080:80 \
|
-p 8080:80 \
|
||||||
-e THREADS=24 \
|
-e THREADS=24 \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
@@ -168,7 +202,7 @@ The import and tile serving processes use 800 MB RAM cache by default, but this
|
|||||||
docker run \
|
docker run \
|
||||||
-p 8080:80 \
|
-p 8080:80 \
|
||||||
-e "OSM2PGSQL_EXTRA_ARGS=-C 4096" \
|
-e "OSM2PGSQL_EXTRA_ARGS=-C 4096" \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
@@ -180,27 +214,24 @@ The database use the autovacuum feature by default. This behavior can be changed
|
|||||||
docker run \
|
docker run \
|
||||||
-p 8080:80 \
|
-p 8080:80 \
|
||||||
-e AUTOVACUUM=off \
|
-e AUTOVACUUM=off \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
-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. You can then use it during the import process as follows:
|
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 \
|
docker run \
|
||||||
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
|
-v /absolute/path/to/luxembourg.osm.pbf:/data/region.osm.pbf \
|
||||||
-v openstreetmap-nodes:/nodes \
|
-v osm-data:/data/database/ \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-e "FLAT_NODES=enabled" \
|
||||||
-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).
|
||||||
@@ -218,7 +249,7 @@ To raise it use `--shm-size` parameter. For example:
|
|||||||
```
|
```
|
||||||
docker run \
|
docker run \
|
||||||
-p 8080:80 \
|
-p 8080:80 \
|
||||||
-v openstreetmap-data:/var/lib/postgresql/12/main \
|
-v osm-data:/data/database/ \
|
||||||
--shm-size="192m" \
|
--shm-size="192m" \
|
||||||
-d overv/openstreetmap-tile-server \
|
-d overv/openstreetmap-tile-server \
|
||||||
run
|
run
|
||||||
|
@@ -4,11 +4,11 @@ services:
|
|||||||
map:
|
map:
|
||||||
image: overv/openstreetmap-tile-server
|
image: overv/openstreetmap-tile-server
|
||||||
volumes:
|
volumes:
|
||||||
- openstreetmap-data:/var/lib/postgresql/12/main
|
- osm-data:/data/database/
|
||||||
ports:
|
ports:
|
||||||
- "8080:80"
|
- "8080:80"
|
||||||
command: "run"
|
command: "run"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
openstreetmap-data:
|
osm-data:
|
||||||
external: true
|
external: true
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/>
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="" />
|
||||||
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js" integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw==" crossorigin=""></script>
|
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
html, body, #map {
|
html, body, #map {
|
||||||
|
@@ -6,11 +6,6 @@ set -e
|
|||||||
# AJT - change directory to mod_tile directory so that we can run replag
|
# AJT - change directory to mod_tile directory so that we can run replag
|
||||||
# and other things directly from this script when run from cron.
|
# and other things directly from this script when run from cron.
|
||||||
# Change the actual location to wherever installed locally.
|
# Change the actual location to wherever installed locally.
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
export PATH=.:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
||||||
ACCOUNT=renderer
|
|
||||||
cd /home/$ACCOUNT/src/mod_tile/
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Extra OSM2PGSQL_OPTIONS may need setting if a tag transform script is
|
# Extra OSM2PGSQL_OPTIONS may need setting if a tag transform script is
|
||||||
# in use. See https://github.com/SomeoneElseOSM/SomeoneElse-style and
|
# in use. See https://github.com/SomeoneElseOSM/SomeoneElse-style and
|
||||||
@@ -19,10 +14,15 @@ cd /home/$ACCOUNT/src/mod_tile/
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
OSMOSIS_BIN=osmosis
|
OSMOSIS_BIN=osmosis
|
||||||
OSM2PGSQL_BIN=osm2pgsql
|
OSM2PGSQL_BIN=osm2pgsql
|
||||||
TRIM_BIN=/home/$ACCOUNT/src/regional/trim_osc.py
|
TRIM_BIN=/home/renderer/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 --number-processes ${THREADS:-4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style ${OSM2PGSQL_EXTRA_ARGS}"
|
OSM2PGSQL_OPTIONS="-d $DBNAME -G --hstore --tag-transform-script /data/style/${NAME_LUA:-openstreetmap-carto.lua} --number-processes ${THREADS:-4} -S /data/style/${NAME_STYLE:-openstreetmap-carto.style} ${OSM2PGSQL_EXTRA_ARGS}"
|
||||||
|
|
||||||
|
# flat-nodes
|
||||||
|
if [ -f /data/database/flat_nodes.bin ]; then
|
||||||
|
OSM2PGSQL_OPTIONS="${OSM2PGSQL_OPTIONS} --flat-nodes /data/database/flat_nodes.bin"
|
||||||
|
fi
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# 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
|
||||||
@@ -30,13 +30,12 @@ OSM2PGSQL_OPTIONS="-d $DBNAME -G --hstore --tag-transform-script /home/renderer/
|
|||||||
# See https://github.com/zverik/regional .
|
# See https://github.com/zverik/regional .
|
||||||
# This area will usually correspond to the data originally loaded.
|
# This area will usually correspond to the data originally loaded.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
TRIM_POLY_FILE="/var/lib/mod_tile/data.poly"
|
TRIM_POLY_FILE="/data/database/region.poly"
|
||||||
TRIM_OPTIONS="-d $DBNAME"
|
TRIM_OPTIONS="-d $DBNAME"
|
||||||
#TRIM_REGION_OPTIONS="-b -14.17 48.85 2.12 61.27"
|
|
||||||
TRIM_REGION_OPTIONS="-p $TRIM_POLY_FILE"
|
TRIM_REGION_OPTIONS="-p $TRIM_POLY_FILE"
|
||||||
|
|
||||||
BASE_DIR=/var/lib/mod_tile
|
BASE_DIR=/data/database
|
||||||
LOG_DIR=/var/log/tiles/
|
LOG_DIR=/var/log/tiles
|
||||||
WORKOSM_DIR=$BASE_DIR/.osmosis
|
WORKOSM_DIR=$BASE_DIR/.osmosis
|
||||||
|
|
||||||
LOCK_FILE=/tmp/openstreetmap-update-expire-lock.txt
|
LOCK_FILE=/tmp/openstreetmap-update-expire-lock.txt
|
||||||
@@ -109,23 +108,27 @@ freelock()
|
|||||||
|
|
||||||
if [ $# -eq 1 ] ; then
|
if [ $# -eq 1 ] ; then
|
||||||
m_info "Initialising Osmosis replication system to $1"
|
m_info "Initialising Osmosis replication system to $1"
|
||||||
mkdir $WORKOSM_DIR
|
mkdir -p $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 "https://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
|
exit 0
|
||||||
# make sure the lockfile is removed when we exit and then claim it
|
fi
|
||||||
|
|
||||||
if ! getlock "$LOCK_FILE"; then
|
# make sure the lockfile is removed when we exit and then claim it
|
||||||
|
if ! getlock "$LOCK_FILE"; then
|
||||||
m_info "pid `cat $LOCK_FILE` still running"
|
m_info "pid `cat $LOCK_FILE` still running"
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e $STOP_FILE ]; then
|
if [ -e $STOP_FILE ]; then
|
||||||
m_info "stopped"
|
m_info "stopped"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Add disk space check from https://github.com/zverik/regional
|
# Add disk space check from https://github.com/zverik/regional
|
||||||
@@ -137,16 +140,16 @@ if `python -c "import os, sys; st=os.statvfs('$BASE_DIR'); sys.exit(1 if st.f_ba
|
|||||||
exit 4
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
seq=`cat $WORKOSM_DIR/state.txt | grep sequenceNumber | cut -d= -f2`
|
seq=`cat $WORKOSM_DIR/state.txt | grep sequenceNumber | cut -d= -f2`
|
||||||
|
|
||||||
m_ok "start import from seq-nr $seq, replag is `osmosis-db_replag -h`"
|
m_ok "start import from seq-nr $seq, replag is `osmosis-db_replag -h`"
|
||||||
|
|
||||||
/bin/cp $WORKOSM_DIR/state.txt $WORKOSM_DIR/last.state.txt
|
/bin/cp $WORKOSM_DIR/state.txt $WORKOSM_DIR/last.state.txt
|
||||||
m_ok "downloading diff"
|
m_ok "downloading diff"
|
||||||
|
|
||||||
if ! $OSMOSIS_BIN --read-replication-interval workingDirectory=$WORKOSM_DIR --simplify-change --write-xml-change $CHANGE_FILE 1>&2 2> "$OSMOSISLOG"; then
|
if ! $OSMOSIS_BIN --read-replication-interval workingDirectory=$WORKOSM_DIR --simplify-change --write-xml-change $CHANGE_FILE 1>&2 2> "$OSMOSISLOG"; then
|
||||||
m_error "Osmosis error"
|
m_error "Osmosis error"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $TRIM_POLY_FILE ] ; then
|
if [ -f $TRIM_POLY_FILE ] ; then
|
||||||
m_ok "filtering diff"
|
m_ok "filtering diff"
|
||||||
@@ -156,27 +159,28 @@ if [ -f $TRIM_POLY_FILE ] ; then
|
|||||||
else
|
else
|
||||||
m_ok "filtering diff skipped"
|
m_ok "filtering diff skipped"
|
||||||
fi
|
fi
|
||||||
m_ok "importing diff"
|
m_ok "importing diff"
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Previously openstreetmap-tiles-update-expire tried to dirty layer
|
# Previously openstreetmap-tiles-update-expire tried to dirty layer
|
||||||
# "$EXPIRY_MAXZOOM - 3" (which was 15) only. Instead we write all expired
|
# "$EXPIRY_MAXZOOM - 3" (which was 15) only. Instead we write all expired
|
||||||
# tiles in range to the list (note the "-" rather than ":" in the "-e"
|
# tiles in range to the list (note the "-" rather than ":" in the "-e"
|
||||||
# parameter).
|
# parameter).
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
if ! $OSM2PGSQL_BIN -a --slim -e$EXPIRY_MINZOOM-$EXPIRY_MAXZOOM $OSM2PGSQL_OPTIONS -o "$EXPIRY_FILE.$$" $CHANGE_FILE 1>&2 2> "$PGSQLLOG"; then
|
if ! $OSM2PGSQL_BIN -a --slim -e$EXPIRY_MINZOOM-$EXPIRY_MAXZOOM $OSM2PGSQL_OPTIONS -o "$EXPIRY_FILE.$$" $CHANGE_FILE 1>&2 2> "$PGSQLLOG"; then
|
||||||
m_error "osm2pgsql error"
|
m_error "osm2pgsql error"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# The lockfile is normally removed before we expire tiles because that is
|
# The lockfile is normally removed before we expire tiles because that is
|
||||||
# something thatcan be done in parallel with further processing. In order to
|
# something that can be done in parallel with further processing. In order to
|
||||||
# avoid rework, if actually rerendering is done rather than just deleting or
|
# avoid rework, if actually rerendering is done rather than just deleting or
|
||||||
# dirtying, it makes sense to move it lower down.
|
# dirtying, it makes sense to move it lower down.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# m_ok "Import complete; removing lock file"
|
# m_ok "Import complete; removing lock file"
|
||||||
# freelock "$LOCK_FILE"
|
# freelock "$LOCK_FILE"
|
||||||
|
m_ok "expiring tiles"
|
||||||
|
|
||||||
m_ok "expiring tiles"
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# When expiring tiles we need to define the style sheet if it's not "default".
|
# When expiring tiles we need to define the style sheet if it's not "default".
|
||||||
# In this case it's "ajt".
|
# In this case it's "ajt".
|
||||||
@@ -186,21 +190,16 @@ fi
|
|||||||
# delete >= $EXPIRY_DELETEFROM and <= $EXPIRY_MAXZOOM.
|
# delete >= $EXPIRY_DELETEFROM and <= $EXPIRY_MAXZOOM.
|
||||||
# The default path to renderd.sock is fixed.
|
# The default path to renderd.sock is fixed.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
if ! render_expired --map=ajt --min-zoom=$EXPIRY_MINZOOM --touch-from=$EXPIRY_TOUCHFROM --delete-from=$EXPIRY_DELETEFROM --max-zoom=$EXPIRY_MAXZOOM -s /var/run/renderd/renderd.sock < "$EXPIRY_FILE.$$" 2>&1 | tail -8 >> "$EXPIRYLOG"; then
|
if ! render_expired --map=ajt --min-zoom=$EXPIRY_MINZOOM --touch-from=$EXPIRY_TOUCHFROM --delete-from=$EXPIRY_DELETEFROM --max-zoom=$EXPIRY_MAXZOOM -s /var/run/renderd/renderd.sock < "$EXPIRY_FILE.$$" 2>&1 | tail -8 >> "$EXPIRYLOG"; then
|
||||||
m_info "Expiry failed"
|
m_info "Expiry failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm "$EXPIRY_FILE.$$"
|
rm "$EXPIRY_FILE.$$"
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Only remove the lock file after expiry (if system is slow we want to delay
|
# Only remove the lock file after expiry (if system is slow we want to delay
|
||||||
# the next import, not have multiple render_expired processes running)
|
# the next import, not have multiple render_expired processes running)
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
freelock "$LOCK_FILE"
|
freelock "$LOCK_FILE"
|
||||||
|
|
||||||
m_ok "Done with import"
|
m_ok "Done with import"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fi
|
|
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
shared_buffers = 128MB
|
shared_buffers = 128MB
|
||||||
min_wal_size = 1GB
|
min_wal_size = 1GB
|
||||||
max_wal_size = 2GB
|
# max_wal_size = 2GB # Overridden below
|
||||||
maintenance_work_mem = 256MB
|
maintenance_work_mem = 256MB
|
||||||
|
|
||||||
# Suggested settings from
|
# Suggested settings from
|
||||||
|
115
run.sh
115
run.sh
@@ -1,9 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
function createPostgresConfig() {
|
function createPostgresConfig() {
|
||||||
cp /etc/postgresql/12/main/postgresql.custom.conf.tmpl /etc/postgresql/12/main/conf.d/postgresql.custom.conf
|
cp /etc/postgresql/14/main/postgresql.custom.conf.tmpl /etc/postgresql/14/main/conf.d/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/14/main/conf.d/postgresql.custom.conf
|
||||||
cat /etc/postgresql/12/main/conf.d/postgresql.custom.conf
|
cat /etc/postgresql/14/main/conf.d/postgresql.custom.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPostgresPassword() {
|
function setPostgresPassword() {
|
||||||
@@ -13,21 +15,36 @@ function setPostgresPassword() {
|
|||||||
if [ "$#" -ne 1 ]; then
|
if [ "$#" -ne 1 ]; then
|
||||||
echo "usage: <import|run>"
|
echo "usage: <import|run>"
|
||||||
echo "commands:"
|
echo "commands:"
|
||||||
echo " import: Set up the database and import /data.osm.pbf"
|
echo " import: Set up the database and import /data/region.osm.pbf"
|
||||||
echo " run: Runs Apache and renderd to serve tiles at /tile/{z}/{x}/{y}.png"
|
echo " run: Runs Apache and renderd to serve tiles at /tile/{z}/{x}/{y}.png"
|
||||||
echo "environment variables:"
|
echo "environment variables:"
|
||||||
echo " THREADS: defines number of threads used for importing / tile rendering"
|
echo " THREADS: defines number of threads used for importing / tile rendering"
|
||||||
echo " UPDATES: consecutive updates (enabled/disabled)"
|
echo " UPDATES: consecutive updates (enabled/disabled)"
|
||||||
|
echo " NAME_LUA: name of .lua script to run as part of the style"
|
||||||
|
echo " NAME_STYLE: name of the .style to use"
|
||||||
|
echo " NAME_MML: name of the .mml file to render to mapnik.xml"
|
||||||
|
echo " NAME_SQL: name of the .sql file to use"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
if [ "$1" = "import" ]; then
|
# if there is no custom style mounted, then use osm-carto
|
||||||
|
if [ ! "$(ls -A /data/style/)" ]; then
|
||||||
|
mv /home/renderer/src/openstreetmap-carto-backup/* /data/style/
|
||||||
|
fi
|
||||||
|
|
||||||
|
# carto build
|
||||||
|
if [ ! -f /data/style/mapnik.xml ]; then
|
||||||
|
cd /data/style/
|
||||||
|
carto ${NAME_MML:-project.mml} > mapnik.xml
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" == "import" ]; then
|
||||||
# Ensure that database directory is in right state
|
# Ensure that database directory is in right state
|
||||||
chown postgres:postgres -R /var/lib/postgresql
|
chown -R postgres: /var/lib/postgresql /data/database/postgres/
|
||||||
if [ ! -f /var/lib/postgresql/12/main/PG_VERSION ]; then
|
if [ ! -f /data/database/postgres/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"
|
sudo -u postgres /usr/lib/postgresql/14/bin/pg_ctl -D /data/database/postgres/ initdb -o "--locale C.UTF-8"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Initialize PostgreSQL
|
# Initialize PostgreSQL
|
||||||
@@ -42,63 +59,103 @@ 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 ] && [ -z "$DOWNLOAD_PBF" ]; then
|
if [ ! -f /data/region.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/region.osm.pbf, so importing Luxembourg as example..."
|
||||||
DOWNLOAD_PBF="https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf"
|
DOWNLOAD_PBF="https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf"
|
||||||
DOWNLOAD_POLY="https://download.geofabrik.de/europe/luxembourg.poly"
|
DOWNLOAD_POLY="https://download.geofabrik.de/europe/luxembourg.poly"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$DOWNLOAD_PBF" ]; then
|
if [ -n "${DOWNLOAD_PBF:-}" ]; then
|
||||||
echo "INFO: Download PBF file: $DOWNLOAD_PBF"
|
echo "INFO: Download PBF file: $DOWNLOAD_PBF"
|
||||||
wget $WGET_ARGS "$DOWNLOAD_PBF" -O /data.osm.pbf
|
wget ${WGET_ARGS:-} "$DOWNLOAD_PBF" -O /data/region.osm.pbf
|
||||||
if [ -n "$DOWNLOAD_POLY" ]; then
|
if [ -n "$DOWNLOAD_POLY" ]; then
|
||||||
echo "INFO: Download PBF-POLY file: $DOWNLOAD_POLY"
|
echo "INFO: Download PBF-POLY file: $DOWNLOAD_POLY"
|
||||||
wget $WGET_ARGS "$DOWNLOAD_POLY" -O /data.poly
|
wget ${WGET_ARGS:-} "$DOWNLOAD_POLY" -O /data/region.poly
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$UPDATES" = "enabled" ]; then
|
if [ "${UPDATES:-}" == "enabled" ] || [ "${UPDATES:-}" == "1" ]; 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
|
REPLICATION_TIMESTAMP=`osmium fileinfo /data/region.osm.pbf | grep 'osmosis_replication_timestamp=' | cut -b35-44`
|
||||||
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.sh $REPLICATION_TIMESTAMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# copy polygon file if available
|
# copy polygon file if available
|
||||||
if [ -f /data.poly ]; then
|
if [ -f /data/region.poly ]; then
|
||||||
sudo -u renderer cp /data.poly /var/lib/mod_tile/data.poly
|
cp /data/region.poly /data/database/region.poly
|
||||||
|
chown renderer: /data/database/region.poly
|
||||||
|
fi
|
||||||
|
|
||||||
|
# flat-nodes
|
||||||
|
if [ "${FLAT_NODES:-}" == "enabled" ] || [ "${FLAT_NODES:-}" == "1" ]; then
|
||||||
|
OSM2PGSQL_EXTRA_ARGS="${OSM2PGSQL_EXTRA_ARGS:-} --flat-nodes /data/database/flat_nodes.bin"
|
||||||
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 --number-processes ${THREADS:-4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style /data.osm.pbf ${OSM2PGSQL_EXTRA_ARGS}
|
sudo -u renderer osm2pgsql -d gis --create --slim -G --hstore \
|
||||||
|
--tag-transform-script /data/style/${NAME_LUA:-openstreetmap-carto.lua} \
|
||||||
|
--number-processes ${THREADS:-4} \
|
||||||
|
-S /data/style/${NAME_STYLE:-openstreetmap-carto.style} \
|
||||||
|
/data/region.osm.pbf \
|
||||||
|
${OSM2PGSQL_EXTRA_ARGS:-} \
|
||||||
|
;
|
||||||
|
|
||||||
|
# old flat-nodes dir
|
||||||
|
if [ -f /nodes/flat_nodes.bin ] && ! [ -f /data/database/flat_nodes.bin ]; then
|
||||||
|
mv /nodes/flat_nodes.bin /data/database/flat_nodes.bin
|
||||||
|
chown renderer: /data/database/flat_nodes.bin
|
||||||
|
fi
|
||||||
|
|
||||||
# Create indexes
|
# Create indexes
|
||||||
sudo -u postgres psql -d gis -f /home/renderer/src/openstreetmap-carto/indexes.sql
|
if [ -f /data/style/${NAME_SQL:-indexes.sql} ]; then
|
||||||
|
sudo -u postgres psql -d gis -f /data/style/${NAME_SQL:-indexes.sql}
|
||||||
|
fi
|
||||||
|
|
||||||
#Import external data
|
#Import external data
|
||||||
sudo chown -R renderer: /home/renderer/src
|
chown -R renderer: /home/renderer/src/ /data/style/
|
||||||
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
|
if [ -f /data/style/scripts/get-external-data.py ] && [ -f /data/style/external-data.yml ]; then
|
||||||
|
sudo -E -u renderer python3 /data/style/scripts/get-external-data.py -c /data/style/external-data.yml -D /data/style/data
|
||||||
|
fi
|
||||||
|
|
||||||
# Register that data has changed for mod_tile caching purposes
|
# Register that data has changed for mod_tile caching purposes
|
||||||
touch /var/lib/mod_tile/planet-import-complete
|
sudo -u renderer touch /data/database/planet-import-complete
|
||||||
|
|
||||||
service postgresql stop
|
service postgresql stop
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = "run" ]; then
|
if [ "$1" == "run" ]; then
|
||||||
# Clean /tmp
|
# Clean /tmp
|
||||||
rm -rf /tmp/*
|
rm -rf /tmp/*
|
||||||
|
|
||||||
|
# migrate old files
|
||||||
|
if [ -f /data/database/PG_VERSION ] && ! [ -d /data/database/postgres/ ]; then
|
||||||
|
mkdir /data/database/postgres/
|
||||||
|
mv /data/database/* /data/database/postgres/
|
||||||
|
fi
|
||||||
|
if [ -f /nodes/flat_nodes.bin ] && ! [ -f /data/database/flat_nodes.bin ]; then
|
||||||
|
mv /nodes/flat_nodes.bin /data/database/flat_nodes.bin
|
||||||
|
fi
|
||||||
|
if [ -f /data/tiles/data.poly ] && ! [ -f /data/database/region.poly ]; then
|
||||||
|
mv /data/tiles/data.poly /data/database/region.poly
|
||||||
|
fi
|
||||||
|
|
||||||
|
# sync planet-import-complete file
|
||||||
|
if [ -f /data/tiles/planet-import-complete ] && ! [ -f /data/database/planet-import-complete ]; then
|
||||||
|
cp /data/tiles/planet-import-complete /data/database/planet-import-complete
|
||||||
|
fi
|
||||||
|
if ! [ -f /data/tiles/planet-import-complete ] && [ -f /data/database/planet-import-complete ]; then
|
||||||
|
cp /data/database/planet-import-complete /data/tiles/planet-import-complete
|
||||||
|
fi
|
||||||
|
|
||||||
# Fix postgres data privileges
|
# Fix postgres data privileges
|
||||||
chown postgres:postgres /var/lib/postgresql -R
|
chown -R postgres: /var/lib/postgresql/ /data/database/postgres/
|
||||||
|
|
||||||
# Configure Apache CORS
|
# Configure Apache CORS
|
||||||
if [ "$ALLOW_CORS" == "enabled" ] || [ "$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
|
||||||
|
|
||||||
@@ -112,7 +169,7 @@ 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" ] || [ "$UPDATES" = "1" ]; then
|
if [ "${UPDATES:-}" == "enabled" ] || [ "${UPDATES:-}" == "1" ]; then
|
||||||
/etc/init.d/cron start
|
/etc/init.d/cron start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user