Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
54624a969e | ||
|
005fe6968f | ||
|
25a661e3da | ||
|
67d127b201 | ||
|
afd62f33a0 | ||
|
21b409863e | ||
|
81c3433055 |
59
.github/workflows/build-and-test.yaml
vendored
59
.github/workflows/build-and-test.yaml
vendored
@@ -21,49 +21,65 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
test:
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- arch : amd64
|
||||||
|
mode : build-and-test
|
||||||
|
- arch : arm64
|
||||||
|
variant : v8
|
||||||
|
mode : build-only
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
VOLUME : osm-db
|
VOLUME : osm-db
|
||||||
CONTAINER : osm-www
|
CONTAINER : osm-www
|
||||||
MOUNT : /data/database/
|
MOUNT : /data/database/
|
||||||
|
PLATFORM : linux/${{ matrix.arch }}${{ (matrix.variant != '' && format('/{0}', matrix.variant)) || '' }}
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
|
with:
|
||||||
|
platforms: ${{ matrix.arch }}
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
-
|
-
|
||||||
name: Environment
|
name: Environment
|
||||||
run : |
|
run : |
|
||||||
echo IMAGE=$(echo ${{ env.IMAGE }} | tr '[:upper:]' '[:lower:]') >>$GITHUB_ENV
|
echo IMAGE=$(echo ${{ env.IMAGE }} | tr '[:upper:]' '[:lower:]') >>$GITHUB_ENV
|
||||||
-
|
-
|
||||||
name: Docker build
|
name: Docker build
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
pull : true
|
pull : true
|
||||||
load : true
|
load : ${{ matrix.mode == 'build-and-test' }}
|
||||||
|
platforms : ${{ env.PLATFORM }}
|
||||||
context : .
|
context : .
|
||||||
file : ./Dockerfile
|
file : ./Dockerfile
|
||||||
tags : ${{env.IMAGE}}:${{env.TAG}}
|
tags : ${{ env.IMAGE }}:${{ env.TAG }}
|
||||||
cache-from : type=gha,scope=${{ github.workflow }}
|
cache-from : type=gha,scope=${{ github.workflow }}:${{ env.PLATFORM }}
|
||||||
cache-to : type=gha,scope=${{ github.workflow }},mode=max
|
cache-to : type=gha,scope=${{ github.workflow }}:${{ env.PLATFORM }},mode=max
|
||||||
-
|
-
|
||||||
name: Import Luxembourg
|
name: Import Luxembourg
|
||||||
|
if : ${{ matrix.mode == 'build-and-test' }}
|
||||||
run : |
|
run : |
|
||||||
docker volume create ${VOLUME}
|
docker volume create ${VOLUME}
|
||||||
docker run --rm --shm-size=128M -v ${VOLUME}:${MOUNT} -e UPDATES=enabled ${IMAGE}:${TAG} import
|
docker run --rm --shm-size=128M -v ${VOLUME}:${MOUNT} -e UPDATES=enabled ${IMAGE}:${TAG} import
|
||||||
-
|
-
|
||||||
name: Start server
|
name: Start server
|
||||||
|
if : ${{ matrix.mode == 'build-and-test' }}
|
||||||
run : |
|
run : |
|
||||||
docker run --rm --shm-size=128M -v ${VOLUME}:${MOUNT} -e UPDATES=enabled -p 80:80 -d --name ${CONTAINER} ${IMAGE}:${TAG} run
|
docker run --shm-size=128M -v ${VOLUME}:${MOUNT} -e UPDATES=enabled -p 80:80 -d --name ${CONTAINER} ${IMAGE}:${TAG} run
|
||||||
sleep 30
|
sleep 30
|
||||||
|
docker logs ${CONTAINER}
|
||||||
-
|
-
|
||||||
name: Download tiles
|
name: Download tiles
|
||||||
|
if : ${{ matrix.mode == 'build-and-test' }}
|
||||||
run : |
|
run : |
|
||||||
curl http://localhost/tile/0/0/0.png --fail -o 000.png
|
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/0.png --fail -o 100.png
|
||||||
@@ -74,12 +90,14 @@ jobs:
|
|||||||
curl http://localhost/tile/18/135536/89345.png --fail -o example.png
|
curl http://localhost/tile/18/135536/89345.png --fail -o example.png
|
||||||
-
|
-
|
||||||
name: Upload tiles
|
name: Upload tiles
|
||||||
|
if : ${{ matrix.mode == 'build-and-test' }}
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: tiles
|
name: tiles
|
||||||
path: '*.png'
|
path: '*.png'
|
||||||
-
|
-
|
||||||
name: Verify tiles
|
name: Verify tiles
|
||||||
|
if : ${{ matrix.mode == 'build-and-test' }}
|
||||||
run : |
|
run : |
|
||||||
sha1sum *.png
|
sha1sum *.png
|
||||||
sha1sum --check <<EOF
|
sha1sum --check <<EOF
|
||||||
@@ -100,6 +118,7 @@ jobs:
|
|||||||
done
|
done
|
||||||
-
|
-
|
||||||
name: Cleanup
|
name: Cleanup
|
||||||
|
if : ${{ matrix.mode == 'build-and-test' }}
|
||||||
run : |
|
run : |
|
||||||
docker rm --force --volumes ${CONTAINER}
|
docker rm --force --volumes ${CONTAINER}
|
||||||
docker volume rm --force ${VOLUME}
|
docker volume rm --force ${VOLUME}
|
||||||
@@ -108,7 +127,7 @@ jobs:
|
|||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
- test
|
- build
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
@@ -122,7 +141,7 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ env.DOCKERHUB_IMAGE }}
|
${{ env.DOCKERHUB_IMAGE }}
|
||||||
@@ -134,33 +153,37 @@ jobs:
|
|||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
|
with:
|
||||||
|
platforms: amd64,arm64
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
if: ${{ env.DOCKERHUB_IMAGE != '' }}
|
if: ${{ env.DOCKERHUB_IMAGE != '' }}
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
-
|
-
|
||||||
name: Login to GHCR
|
name: Login to GHCR
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry : ghcr.io
|
registry : ghcr.io
|
||||||
username : ${{ github.repository_owner }}
|
username : ${{ github.repository_owner }}
|
||||||
password : ${{ secrets.GITHUB_TOKEN }}
|
password : ${{ secrets.GITHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
pull : true
|
pull : true
|
||||||
push : true
|
push : true
|
||||||
|
platforms : linux/amd64,linux/arm64/v8
|
||||||
context : .
|
context : .
|
||||||
file : ./Dockerfile
|
file : ./Dockerfile
|
||||||
tags : ${{ steps.meta.outputs.tags }}
|
tags : ${{ steps.meta.outputs.tags }}
|
||||||
labels : ${{ steps.meta.outputs.labels }}
|
labels : ${{ steps.meta.outputs.labels }}
|
||||||
cache-from : type=gha,scope=${{ github.workflow }}
|
cache-from: |
|
||||||
cache-to : type=gha,scope=${{ github.workflow }},mode=max
|
type=gha,scope=${{ github.workflow }}:linux/amd64
|
||||||
|
type=gha,scope=${{ github.workflow }}:linux/arm64/v8
|
||||||
|
149
Dockerfile
149
Dockerfile
@@ -1,88 +1,22 @@
|
|||||||
FROM ubuntu:20.04 AS compiler-common
|
FROM ubuntu:22.04 AS compiler-common
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
git-core \
|
git-core \
|
||||||
checkinstall \
|
|
||||||
g++ \
|
|
||||||
gnupg2 \
|
|
||||||
make \
|
|
||||||
tar \
|
|
||||||
wget \
|
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
&& apt-get update
|
&& 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
|
FROM compiler-common AS compiler-stylesheet
|
||||||
RUN cd ~ \
|
RUN cd ~ \
|
||||||
&& git clone --single-branch --branch v5.4.0 https://github.com/gravitystorm/openstreetmap-carto.git --depth 1 \
|
&& git clone --single-branch --branch v5.4.0 https://github.com/gravitystorm/openstreetmap-carto.git --depth 1 \
|
||||||
&& cd openstreetmap-carto \
|
&& cd openstreetmap-carto \
|
||||||
|
&& sed -i 's/, "unifont Medium", "Unifont Upper Medium"//g' style/fonts.mss \
|
||||||
|
&& sed -i 's/"Noto Sans Tibetan Regular",//g' style/fonts.mss \
|
||||||
|
&& sed -i 's/"Noto Sans Tibetan Bold",//g' style/fonts.mss \
|
||||||
|
&& sed -i 's/Noto Sans Syriac Eastern Regular/Noto Sans Syriac Regular/g' style/fonts.mss \
|
||||||
&& rm -rf .git
|
&& rm -rf .git
|
||||||
|
|
||||||
###########################################################################################################
|
###########################################################################################################
|
||||||
@@ -97,13 +31,16 @@ RUN mkdir -p /home/renderer/src \
|
|||||||
|
|
||||||
###########################################################################################################
|
###########################################################################################################
|
||||||
|
|
||||||
FROM ubuntu:20.04 AS final
|
FROM ubuntu:22.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
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
ENV AUTOVACUUM=on
|
ENV AUTOVACUUM=on
|
||||||
ENV UPDATES=disabled
|
ENV UPDATES=disabled
|
||||||
|
ENV REPLICATION_URL=https://planet.openstreetmap.org/replication/hour/
|
||||||
|
ENV MAX_INTERVAL_SECONDS=3600
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
# Get packages
|
# Get packages
|
||||||
@@ -111,36 +48,46 @@ RUN apt-get update \
|
|||||||
&& apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
apache2 \
|
apache2 \
|
||||||
cron \
|
cron \
|
||||||
|
dateutils \
|
||||||
|
fonts-hanazono \
|
||||||
fonts-noto-cjk \
|
fonts-noto-cjk \
|
||||||
fonts-noto-hinted \
|
fonts-noto-hinted \
|
||||||
fonts-noto-unhinted \
|
fonts-noto-unhinted \
|
||||||
|
fonts-unifont \
|
||||||
gnupg2 \
|
gnupg2 \
|
||||||
gdal-bin \
|
gdal-bin \
|
||||||
liblua5.3-dev \
|
liblua5.3-dev \
|
||||||
lua5.3 \
|
lua5.3 \
|
||||||
mapnik-utils \
|
mapnik-utils \
|
||||||
npm \
|
npm \
|
||||||
|
osm2pgsql \
|
||||||
osmium-tool \
|
osmium-tool \
|
||||||
osmosis \
|
osmosis \
|
||||||
|
postgresql-14 \
|
||||||
|
postgresql-14-postgis-3 \
|
||||||
|
postgresql-14-postgis-3-scripts \
|
||||||
|
postgis \
|
||||||
python-is-python3 \
|
python-is-python3 \
|
||||||
python3-mapnik \
|
python3-mapnik \
|
||||||
python3-lxml \
|
python3-lxml \
|
||||||
python3-psycopg2 \
|
python3-psycopg2 \
|
||||||
python3-shapely \
|
python3-shapely \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
|
renderd \
|
||||||
sudo \
|
sudo \
|
||||||
ttf-unifont \
|
|
||||||
wget \
|
wget \
|
||||||
&& 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}/
|
||||||
|
|
||||||
RUN adduser --disabled-password --gecos "" renderer
|
RUN adduser --disabled-password --gecos "" renderer
|
||||||
|
|
||||||
|
# Get Noto Emoji Regular font, despite it being deprecated by Google
|
||||||
|
RUN wget https://github.com/googlefonts/noto-emoji/blob/9a5261d871451f9b5183c93483cbd68ed916b1e9/fonts/NotoEmoji-Regular.ttf?raw=true --content-disposition -P /usr/share/fonts/
|
||||||
|
|
||||||
|
# For some reason this one is missing in the default packages
|
||||||
|
RUN wget https://github.com/stamen/terrain-classic/blob/master/fonts/unifont-Medium.ttf?raw=true --content-disposition -P /usr/share/fonts/
|
||||||
|
|
||||||
# Install python libraries
|
# Install python libraries
|
||||||
RUN pip3 install \
|
RUN pip3 install \
|
||||||
requests \
|
requests \
|
||||||
@@ -151,11 +98,7 @@ RUN pip3 install \
|
|||||||
RUN npm install -g carto@0.18.2
|
RUN npm install -g carto@0.18.2
|
||||||
|
|
||||||
# Configure Apache
|
# Configure Apache
|
||||||
RUN mkdir /var/lib/mod_tile \
|
RUN echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \
|
||||||
&& chown renderer /var/lib/mod_tile \
|
|
||||||
&& mkdir /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 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
|
||||||
@@ -179,43 +122,29 @@ RUN chown -R postgres:postgres /var/lib/postgresql \
|
|||||||
&& echo "host all all ::/0 md5" >> /etc/postgresql/14/main/pg_hba.conf
|
&& echo "host all all ::/0 md5" >> /etc/postgresql/14/main/pg_hba.conf
|
||||||
|
|
||||||
# Create volume directories
|
# Create volume directories
|
||||||
RUN mkdir -p /data/database/ \
|
RUN mkdir -p /run/renderd/ \
|
||||||
|
&& mkdir -p /data/database/ \
|
||||||
&& mkdir -p /data/style/ \
|
&& mkdir -p /data/style/ \
|
||||||
&& mkdir -p /home/renderer/src/ \
|
&& mkdir -p /home/renderer/src/ \
|
||||||
&& chown -R renderer: /data/ \
|
&& chown -R renderer: /data/ \
|
||||||
&& chown -R renderer: /home/renderer/src/ \
|
&& chown -R renderer: /home/renderer/src/ \
|
||||||
|
&& chown -R renderer: /run/renderd \
|
||||||
&& mv /var/lib/postgresql/14/main/ /data/database/postgres/ \
|
&& mv /var/lib/postgresql/14/main/ /data/database/postgres/ \
|
||||||
&& mv /var/lib/mod_tile/ /data/tiles/ \
|
&& mv /var/cache/renderd/tiles/ /data/tiles/ \
|
||||||
|
&& chown -R renderer: /data/tiles \
|
||||||
&& ln -s /data/database/postgres /var/lib/postgresql/14/main \
|
&& ln -s /data/database/postgres /var/lib/postgresql/14/main \
|
||||||
&& ln -s /data/style /home/renderer/src/openstreetmap-carto \
|
&& ln -s /data/style /home/renderer/src/openstreetmap-carto \
|
||||||
&& ln -s /data/tiles /var/lib/mod_tile \
|
&& ln -s /data/tiles /var/cache/renderd/tiles \
|
||||||
;
|
;
|
||||||
|
|
||||||
# Install PostGIS
|
RUN echo '[default] \n\
|
||||||
COPY --from=compiler-postgis postgis_src/postgis-src_3.2.1-1_amd64.deb .
|
URI=/tile/ \n\
|
||||||
RUN dpkg -i postgis-src_3.2.1-1_amd64.deb \
|
TILEDIR=/var/cache/renderd/tiles \n\
|
||||||
&& rm postgis-src_3.2.1-1_amd64.deb
|
XML=/home/renderer/src/openstreetmap-carto/mapnik.xml \n\
|
||||||
|
HOST=localhost \n\
|
||||||
# Install osm2pgsql
|
TILESIZE=256 \n\
|
||||||
COPY --from=compiler-osm2pgsql /root/osm2pgsql/build/build_1-1_amd64.deb .
|
MAXZOOM=20' >> /etc/renderd.conf \
|
||||||
RUN dpkg -i build_1-1_amd64.deb \
|
&& sed -i 's,/usr/share/fonts/truetype,/usr/share/fonts,g' /etc/renderd.conf
|
||||||
&& 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
|
# Install helper script
|
||||||
COPY --from=compiler-helper-script /home/renderer/src/regional /home/renderer/src/regional
|
COPY --from=compiler-helper-script /home/renderer/src/regional /home/renderer/src/regional
|
||||||
|
27
README.md
27
README.md
@@ -126,6 +126,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 REPLICATION_URL=https://planet.openstreetmap.org/replication/minute/ \
|
||||||
|
-e MAX_INTERVAL_SECONDS=60 \
|
||||||
-e UPDATES=enabled \
|
-e UPDATES=enabled \
|
||||||
-v osm-data:/data/database/ \
|
-v osm-data:/data/database/ \
|
||||||
-v osm-tiles:/data/tiles/ \
|
-v osm-tiles:/data/tiles/ \
|
||||||
@@ -135,6 +137,29 @@ docker run \
|
|||||||
|
|
||||||
This will enable a background process that automatically downloads changes from the OpenStreetMap server, filters them for the relevant region polygon you specified, updates the database and finally marks the affected tiles for rerendering.
|
This will enable a background process that automatically downloads changes from the OpenStreetMap server, filters them for the relevant region polygon you specified, updates the database and finally marks the affected tiles for rerendering.
|
||||||
|
|
||||||
|
### Tile expiration (optional)
|
||||||
|
|
||||||
|
Specify custom tile expiration settings to control which zoom level tiles are marked as expired when an update is performed. Tiles can be marked as expired in the cache (TOUCHFROM), but will still be served
|
||||||
|
until a new tile has been rendered, or deleted from the cache (DELETEFROM), so nothing will be served until a new tile has been rendered.
|
||||||
|
|
||||||
|
The example tile expiration values below are the default values.
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run \
|
||||||
|
-p 8080:80 \
|
||||||
|
-e REPLICATION_URL=https://planet.openstreetmap.org/replication/minute/ \
|
||||||
|
-e MAX_INTERVAL_SECONDS=60 \
|
||||||
|
-e UPDATES=enabled \
|
||||||
|
-e EXPIRY_MINZOOM=13 \
|
||||||
|
-e EXPIRY_TOUCHFROM=13 \
|
||||||
|
-e EXPIRY_DELETEFROM=19 \
|
||||||
|
-e EXPIRY_MAXZOOM=20 \
|
||||||
|
-v osm-data:/data/database/ \
|
||||||
|
-v osm-tiles:/data/tiles/ \
|
||||||
|
-d overv/openstreetmap-tile-server \
|
||||||
|
run
|
||||||
|
```
|
||||||
|
|
||||||
### 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 `enabled`:
|
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`:
|
||||||
@@ -244,7 +269,7 @@ You can find an example of the import performance to expect with this image on t
|
|||||||
|
|
||||||
If you encounter such entries in the log, it will mean that the default shared memory limit (64 MB) is too low for the container and it should be raised:
|
If you encounter such entries in the log, it will mean that the default shared memory limit (64 MB) is too low for the container and it should be raised:
|
||||||
```
|
```
|
||||||
renderd[121]: ERROR: failed to render TILE ajt 2 0-3 0-3
|
renderd[121]: ERROR: failed to render TILE default 2 0-3 0-3
|
||||||
renderd[121]: reason: Postgis Plugin: ERROR: could not resize shared memory segment "/PostgreSQL.790133961" to 12615680 bytes: ### No space left on device
|
renderd[121]: reason: Postgis Plugin: ERROR: could not resize shared memory segment "/PostgreSQL.790133961" to 12615680 bytes: ### No space left on device
|
||||||
```
|
```
|
||||||
To raise it use `--shm-size` parameter. For example:
|
To raise it use `--shm-size` parameter. For example:
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
<VirtualHost *:80>
|
<VirtualHost *:80>
|
||||||
ServerAdmin webmaster@localhost
|
ServerAdmin webmaster@localhost
|
||||||
|
|
||||||
LoadTileConfigFile /usr/local/etc/renderd.conf
|
AddTileConfig /tile/ default
|
||||||
ModTileRenderdSocketName /var/run/renderd/renderd.sock
|
LoadTileConfigFile /etc/renderd.conf
|
||||||
|
ModTileRenderdSocketName /run/renderd/renderd.sock
|
||||||
ModTileRequestTimeout 0
|
ModTileRequestTimeout 0
|
||||||
ModTileMissingRequestTimeout 30
|
ModTileMissingRequestTimeout 30
|
||||||
|
|
||||||
|
31
openstreetmap-tiles-update-expire.sh
Normal file → Executable file
31
openstreetmap-tiles-update-expire.sh
Normal file → Executable file
@@ -3,7 +3,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# AJT - change directory to mod_tile directory so that we can run replag
|
# 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.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
@@ -56,10 +56,10 @@ RUNLOG=$LOG_DIR/run.log
|
|||||||
# Here we expire (but don't immediately rerender) tiles between zoom levels
|
# Here we expire (but don't immediately rerender) tiles between zoom levels
|
||||||
# 13 and 18 and delete between 19 and 20.
|
# 13 and 18 and delete between 19 and 20.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
EXPIRY_MINZOOM=13
|
EXPIRY_MINZOOM=${EXPIRY_MINZOOM:="13"}
|
||||||
EXPIRY_TOUCHFROM=13
|
EXPIRY_TOUCHFROM=${EXPIRY_TOUCHFROM:="13"}
|
||||||
EXPIRY_DELETEFROM=19
|
EXPIRY_DELETEFROM=${EXPIRY_DELETEFROM:="19"}
|
||||||
EXPIRY_MAXZOOM=20
|
EXPIRY_MAXZOOM=${EXPIRY_MAXZOOM:="20"}
|
||||||
|
|
||||||
#*************************************************************************
|
#*************************************************************************
|
||||||
#*************************************************************************
|
#*************************************************************************
|
||||||
@@ -109,14 +109,16 @@ 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 -p $WORKOSM_DIR
|
mkdir -p $WORKOSM_DIR
|
||||||
|
$OSMOSIS_BIN -v 5 --read-replication-interval-init workingDirectory=$WORKOSM_DIR 1>&2 2> "$OSMOSISLOG"
|
||||||
|
|
||||||
$OSMOSIS_BIN --read-replication-interval-init workingDirectory=$WORKOSM_DIR 1>&2 2> "$OSMOSISLOG"
|
init_seq=$(/usr/lib/python3-pyosmium/pyosmium-get-changes --server $REPLICATION_URL -D $1)
|
||||||
|
url_dynamicPart=$(printf %09d $init_seq | sed 's_\([0-9][0-9][0-9]\)\([0-9][0-9][0-9]\)\([0-9][0-9][0-9]\)_\1/\2/\3_')
|
||||||
|
wget $REPLICATION_URL/$url_dynamicPart.state.txt -O $WORKOSM_DIR/state.txt
|
||||||
|
|
||||||
wget "https://replicate-sequences.osm.mazdermind.de/?"$1"T00:00:00Z" -O $WORKOSM_DIR/state.txt
|
cat > $WORKOSM_DIR/configuration.txt <<- EOM
|
||||||
|
baseUrl=$REPLICATION_URL
|
||||||
mv $WORKOSM_DIR/configuration.txt $WORKOSM_DIR/configuration_orig.txt
|
maxInterval=$MAX_INTERVAL_SECONDS
|
||||||
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
|
EOM
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# make sure the lockfile is removed when we exit and then claim it
|
# make sure the lockfile is removed when we exit and then claim it
|
||||||
@@ -141,8 +143,9 @@ if `python -c "import os, sys; st=os.statvfs('$BASE_DIR'); sys.exit(1 if st.f_ba
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
seq=`cat $WORKOSM_DIR/state.txt | grep sequenceNumber | cut -d= -f2`
|
seq=`cat $WORKOSM_DIR/state.txt | grep sequenceNumber | cut -d= -f2`
|
||||||
|
replag=`dateutils.ddiff $(cat $WORKOSM_DIR/state.txt | grep timestamp | cut -d "=" -f 2 | sed 's,\\\,,g') now`
|
||||||
|
|
||||||
m_ok "start import from seq-nr $seq, replag is `osmosis-db_replag -h`"
|
m_ok "start import from seq-nr $seq, replag is $replag"
|
||||||
|
|
||||||
/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"
|
||||||
@@ -182,15 +185,13 @@ fi
|
|||||||
m_ok "expiring tiles"
|
m_ok "expiring tiles"
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# When expiring tiles we need to define the style sheet if it's not "default".
|
|
||||||
# In this case it's "ajt".
|
|
||||||
# Previously all tiles on the "dirty" list between $EXPIRY_MINZOOM and
|
# Previously all tiles on the "dirty" list between $EXPIRY_MINZOOM and
|
||||||
# $EXPIRY_MAXZOOM were dirtied. We currently re-render
|
# $EXPIRY_MAXZOOM were dirtied. We currently re-render
|
||||||
# tiles >= $EXPIRY_MINZOOM and < $EXPIRY_DELETEFROM, expiry from 14 and
|
# tiles >= $EXPIRY_MINZOOM and < $EXPIRY_DELETEFROM, expiry from 14 and
|
||||||
# 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=default --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
|
||||||
|
|
||||||
|
15
run.sh
15
run.sh
@@ -70,7 +70,7 @@ if [ "$1" == "import" ]; then
|
|||||||
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/region.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/region.poly
|
wget ${WGET_ARGS:-} "$DOWNLOAD_POLY" -O /data/region.poly
|
||||||
fi
|
fi
|
||||||
@@ -78,10 +78,10 @@ if [ "$1" == "import" ]; then
|
|||||||
|
|
||||||
if [ "${UPDATES:-}" == "enabled" ] || [ "${UPDATES:-}" == "1" ]; 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)
|
||||||
REPLICATION_TIMESTAMP=`osmium fileinfo /data/region.osm.pbf | grep 'osmosis_replication_timestamp=' | cut -b35-44`
|
REPLICATION_TIMESTAMP=`osmium fileinfo -g header.option.osmosis_replication_timestamp /data/region.osm.pbf`
|
||||||
|
|
||||||
# initial setup of osmosis workspace (for consecutive updates)
|
# initial setup of osmosis workspace (for consecutive updates)
|
||||||
sudo -u renderer openstreetmap-tiles-update-expire.sh $REPLICATION_TIMESTAMP
|
sudo -E -u renderer openstreetmap-tiles-update-expire.sh $REPLICATION_TIMESTAMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# copy polygon file if available
|
# copy polygon file if available
|
||||||
@@ -168,11 +168,16 @@ if [ "$1" == "run" ]; then
|
|||||||
setPostgresPassword
|
setPostgresPassword
|
||||||
|
|
||||||
# Configure renderd threads
|
# Configure renderd threads
|
||||||
sed -i -E "s/num_threads=[0-9]+/num_threads=${THREADS:-4}/g" /usr/local/etc/renderd.conf
|
sed -i -E "s/num_threads=[0-9]+/num_threads=${THREADS:-4}/g" /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
|
||||||
|
sudo -u renderer touch /var/log/tiles/run.log; tail -f /var/log/tiles/run.log >> /proc/1/fd/1 &
|
||||||
|
sudo -u renderer touch /var/log/tiles/osmosis.log; tail -f /var/log/tiles/osmosis.log >> /proc/1/fd/1 &
|
||||||
|
sudo -u renderer touch /var/log/tiles/expiry.log; tail -f /var/log/tiles/expiry.log >> /proc/1/fd/1 &
|
||||||
|
sudo -u renderer touch /var/log/tiles/osm2pgsql.log; tail -f /var/log/tiles/osm2pgsql.log >> /proc/1/fd/1 &
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run while handling docker stop's SIGTERM
|
# Run while handling docker stop's SIGTERM
|
||||||
@@ -181,7 +186,7 @@ if [ "$1" == "run" ]; then
|
|||||||
}
|
}
|
||||||
trap stop_handler SIGTERM
|
trap stop_handler SIGTERM
|
||||||
|
|
||||||
sudo -u renderer renderd -f -c /usr/local/etc/renderd.conf &
|
sudo -u renderer renderd -f -c /etc/renderd.conf &
|
||||||
child=$!
|
child=$!
|
||||||
wait "$child"
|
wait "$child"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user