Compare commits

..

28 Commits

Author SHA1 Message Date
Hendrik Behme
24170a794a updated login
All checks were successful
Build docker image / push (push) Successful in 50s
2024-08-13 13:26:33 +02:00
Hendrik Behme
e57fde375c updated login
Some checks failed
Build docker image / push (push) Has been cancelled
2024-08-13 13:26:08 +02:00
Hendrik Behme
016e08d658 try with hard coded values
Some checks failed
Build docker image / push (push) Failing after 6s
2024-08-13 13:11:27 +02:00
Hendrik Behme
830305d03e next try
Some checks failed
Build docker image / push (push) Failing after 5s
2024-08-13 13:08:31 +02:00
Hendrik Behme
28e5de0d23 updated vars
Some checks failed
Build docker image / push (push) Failing after 6s
2024-08-13 13:02:03 +02:00
Hendrik Behme
588e6db76a corrected syntax
Some checks failed
Build docker image / push (push) Failing after 5s
2024-08-13 12:57:22 +02:00
Hendrik Behme
89f1ecadbc remved comment 2024-08-13 12:56:17 +02:00
Hendrik Behme
99893aea87 replaced build action 2024-08-13 12:49:35 +02:00
Hendrik Behme
8d3dfc24bc removed some weird? lines from config
Some checks failed
Build docker image / push (push) Failing after 2m30s
2024-08-13 10:42:43 +02:00
Hendrik Behme
f766278f37 updated dest reg
Some checks failed
Build docker image / push (push) Failing after 2m36s
2024-08-08 02:17:29 +02:00
Hendrik Behme
2664fc4a11 added login
Some checks failed
Build docker image / push (push) Failing after 2m34s
2024-08-08 02:10:33 +02:00
Hendrik Behme
e30cde2a0b removed blocking attriubute
Some checks failed
Build docker image / push (push) Failing after 3m22s
2024-08-08 01:47:52 +02:00
Hendrik Behme
a9956c194b updated git workflows
Some checks are pending
Build docker image / push (push) Blocked by required conditions
2024-08-08 01:43:29 +02:00
Hendrik Behme
9ec73992db removed old docker file and added gitea runner 2024-08-08 01:34:29 +02:00
8982d7d3da added postgres improvments and some general optimisations 2024-08-07 23:48:22 +02:00
Kai Liebscher
6088b9b37f
upgrade carto from v0.18.2 to v1.2.0 (#355) (#359)
Co-authored-by: Kai Liebscher <kliebscher@micromata.de>
2023-06-25 12:34:51 +02:00
Curtis Yung
61270b8bff
Add support to PostgreSQL 15 (#356)
* Update Dockerfile

add support to PostgreSQL 15 and alter encryption method to scram-sha-256 instead of md5

* Update run.sh

add support to PostgreSQL 15
2023-03-18 21:45:25 +01:00
galewis2
f6a6ad846a
Fix path for consistency (#314) 2023-03-18 21:14:32 +01:00
Stepan
e144c4873b
readme give possibility to copy/paste command into linux terminal (#368) 2023-03-18 21:10:32 +01:00
Robin C. Ladiges
10571b77b7
validate version tags (#308)
so non-semver tags don't trigger a deployment that will fail.

It's not a normal regexp syntax. Dots `.` will only match dots and not any characters.
2022-09-27 10:04:05 -04:00
Mikael Wikstrom
a814c0306a
upgrade leaflet from v1.7.1 to v1.8.0 (#315)
Leaflet 1.8.0	Stable version, released on April 18, 2022.
Leaflet 1.7.1	Previous stable version, released on September 3, 2020.

install leaflet localy so server works offline

Co-authored-by: galewis2 <62433564+galewis2@users.noreply.github.com>
2022-09-27 10:03:13 -04:00
Mikael Wikstrom
fdacfe78ef
Add favicon.ico (#316) 2022-09-27 10:00:44 -04:00
galewis2
54624a969e
Update Dockerfile (#307) 2022-08-03 23:40:03 +02:00
balchen
005fe6968f
Added new environment variables for tile expiration to README.md (#299) 2022-07-26 23:10:49 +02:00
galewis2
25a661e3da
Actually allow modifying the replication URL (#297) 2022-07-22 09:18:24 -04:00
balchen
67d127b201
Use tile expiration settings from env if set, or default values as be… (#296)
* Use tile expiration settings from env if set, or default values as before.

* Update openstreetmap-tiles-update-expire.sh

Co-authored-by: galewis2 <62433564+galewis2@users.noreply.github.com>
2022-07-22 13:33:07 +02:00
Robin C. Ladiges
afd62f33a0
multiarch build for additional linux/arm64/v8 support (#292)
* multiarch build for additional linux/arm64/v8 and linux/arm/v7 support

This commit fixes issue #291

* print logs of run command

* drop arm/v7 for now (untested)

* build arm64/v8 parallel during the build stage (without testing the image)
2022-07-19 08:59:17 +02:00
galewis2
21b409863e
Simplify parsing of timestamp (#294) 2022-07-15 08:19:46 -04:00
10 changed files with 199 additions and 76 deletions

View File

@ -0,0 +1,32 @@
name: Build docker image
run-name: ${{ gitea.actor }} is runs ci pipeline
on: [ push ]
jobs:
push:
runs-on: ubuntu-latest
if: gitea.ref == 'refs/heads/master'
steps:
- uses: https://github.com/actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: git.whimsoc.dev/${{gitea.repository_owner}}/openstreetmap-tile-server
username: ${{ gitea.repository_owner }}
password: ${{ secrets.PAT }}
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Build and push Docker image
# uses: https://github.com/docker/build-push-action@v6
# with:
# context: .
# file: ./Dockerfile
# push: true
# tags: "git.whimsoc.dev/${{gitea.repository_owner}}/openstreetmap-tile-server:${{gitea.sha}},git.whimsoc.dev/${{gitea.repository_owner}}/openstreetmap-tile-server:latest"
- name: Build and push
run: |
TODAY=$(date +'%Y-%m-%d')
docker build -t git.whimsoc.dev/${{gitea.repository_owner}}/openstreetmap-tile-server:${TODAY} -t git.whimsoc.dev/${{gitea.repository_owner}}/openstreetmap-tile-server:latest .
docker push git.whimsoc.dev/${{gitea.repository_owner}}/openstreetmap-tile-server:${TODAY}
docker push git.whimsoc.dev/${{gitea.repository_owner}}/openstreetmap-tile-server:latest

View File

@ -5,10 +5,10 @@ on:
branches: branches:
- master - master
tags: tags:
- 'v*' - 'v[0-9]+.[0-9]+.[0-9]+'
pull_request: # pull_request:
branches: # branches:
- master # - master
# cancel outdated jobs for the same reference # cancel outdated jobs for the same reference
concurrency: concurrency:
@ -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

View File

@ -1,11 +1,17 @@
FROM ubuntu:22.04 AS compiler-common FROM ubuntu:22.04 AS compiler-common
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
git-core \ ca-certificates gnupg lsb-release locales \
ca-certificates \ wget curl \
&& apt-get update git-core unzip unrar \
&& locale-gen $LANG && update-locale LANG=$LANG \
&& sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-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 -y upgrade
########################################################################################################### ###########################################################################################################
@ -13,6 +19,10 @@ 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
########################################################################################################### ###########################################################################################################
@ -27,13 +37,17 @@ RUN mkdir -p /home/renderer/src \
########################################################################################################### ###########################################################################################################
FROM ubuntu:22.04 AS final FROM compiler-common 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
ENV PG_VERSION 15
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
@ -42,6 +56,7 @@ RUN apt-get update \
apache2 \ apache2 \
cron \ cron \
dateutils \ dateutils \
fonts-hanazono \
fonts-noto-cjk \ fonts-noto-cjk \
fonts-noto-hinted \ fonts-noto-hinted \
fonts-noto-unhinted \ fonts-noto-unhinted \
@ -55,9 +70,9 @@ RUN apt-get update \
osm2pgsql \ osm2pgsql \
osmium-tool \ osmium-tool \
osmosis \ osmosis \
postgresql-14 \ postgresql-$PG_VERSION \
postgresql-14-postgis-3 \ postgresql-$PG_VERSION-postgis-3 \
postgresql-14-postgis-3-scripts \ postgresql-$PG_VERSION-postgis-3-scripts \
postgis \ postgis \
python-is-python3 \ python-is-python3 \
python3-mapnik \ python3-mapnik \
@ -67,13 +82,19 @@ RUN apt-get update \
python3-pip \ python3-pip \
renderd \ renderd \
sudo \ sudo \
wget \ vim \
&& 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 \
@ -81,17 +102,26 @@ RUN pip3 install \
pyyaml pyyaml
# Install carto for stylesheet # Install carto for stylesheet
RUN npm install -g carto@0.18.2 RUN npm install -g carto@1.2.0
# Configure Apache # Configure Apache
RUN echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \ RUN 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
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
# leaflet
COPY leaflet-demo.html /var/www/html/index.html
RUN cd /var/www/html/ \
&& wget https://github.com/Leaflet/Leaflet/releases/download/v1.8.0/leaflet.zip \
&& unzip leaflet.zip \
&& rm leaflet.zip
# Icon
RUN wget -O /var/www/html/favicon.ico https://www.openstreetmap.org/favicon.ico
# Copy update scripts # Copy update scripts
COPY openstreetmap-tiles-update-expire.sh /usr/bin/ COPY openstreetmap-tiles-update-expire.sh /usr/bin/
RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire.sh \ RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire.sh \
@ -101,11 +131,11 @@ RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire.sh \
&& echo "* * * * * renderer openstreetmap-tiles-update-expire.sh\n" >> /etc/crontab && echo "* * * * * renderer openstreetmap-tiles-update-expire.sh\n" >> /etc/crontab
# Configure PosgtreSQL # Configure PosgtreSQL
COPY postgresql.custom.conf.tmpl /etc/postgresql/14/main/ COPY postgresql.custom.conf.tmpl /etc/postgresql/$PG_VERSION/main/
RUN chown -R postgres:postgres /var/lib/postgresql \ RUN chown -R postgres:postgres /var/lib/postgresql \
&& chown postgres:postgres /etc/postgresql/14/main/postgresql.custom.conf.tmpl \ && chown postgres:postgres /etc/postgresql/$PG_VERSION/main/postgresql.custom.conf.tmpl \
&& echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/14/main/pg_hba.conf \ && echo "host all all 0.0.0.0/0 scram-sha-256" >> /etc/postgresql/$PG_VERSION/main/pg_hba.conf \
&& echo "host all all ::/0 md5" >> /etc/postgresql/14/main/pg_hba.conf && echo "host all all ::/0 scram-sha-256" >> /etc/postgresql/$PG_VERSION/main/pg_hba.conf
# Create volume directories # Create volume directories
RUN mkdir -p /run/renderd/ \ RUN mkdir -p /run/renderd/ \
@ -115,10 +145,10 @@ RUN mkdir -p /run/renderd/ \
&& 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 \ && chown -R renderer: /run/renderd \
&& mv /var/lib/postgresql/14/main/ /data/database/postgres/ \ && mv /var/lib/postgresql/$PG_VERSION/main/ /data/database/postgres/ \
&& mv /var/cache/renderd/tiles/ /data/tiles/ \ && mv /var/cache/renderd/tiles/ /data/tiles/ \
&& chown -R renderer: /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/$PG_VERSION/main \
&& ln -s /data/style /home/renderer/src/openstreetmap-carto \ && ln -s /data/style /home/renderer/src/openstreetmap-carto \
&& ln -s /data/tiles /var/cache/renderd/tiles \ && ln -s /data/tiles /var/cache/renderd/tiles \
; ;
@ -129,7 +159,8 @@ TILEDIR=/var/cache/renderd/tiles \n\
XML=/home/renderer/src/openstreetmap-carto/mapnik.xml \n\ XML=/home/renderer/src/openstreetmap-carto/mapnik.xml \n\
HOST=localhost \n\ HOST=localhost \n\
TILESIZE=256 \n\ TILESIZE=256 \n\
MAXZOOM=20' >> /etc/renderd.conf MAXZOOM=20' >> /etc/renderd.conf \
&& sed -i 's,/usr/share/fonts/truetype,/usr/share/fonts,g' /etc/renderd.conf
# 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

View File

@ -67,10 +67,10 @@ By default the container will use openstreetmap-carto if it is not specified. Ho
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 \
-e NAME_LUA=sample.lua -e NAME_LUA=sample.lua \
-e NAME_STYLE=test.style -e NAME_STYLE=test.style \
-e NAME_MML=project.mml -e NAME_MML=project.mml \
-e NAME_SQL=test.sql -e NAME_SQL=test.sql \
-v /home/user/openstreetmap-carto-modified:/data/style/ \ -v /home/user/openstreetmap-carto-modified:/data/style/ \
-v osm-data:/data/database/ \ -v osm-data:/data/database/ \
overv/openstreetmap-tile-server \ overv/openstreetmap-tile-server \
@ -137,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`:

25
docker-compose.yaml Normal file
View File

@ -0,0 +1,25 @@
services:
map:
image: git.whimsoc.dev/hendrik/openstreetmap-tile-server:latest
environment:
- UPDATES=enabled
- MAX_INTERVAL_SECONDS=3600
- REPLICATION_URL=https://planet.openstreetmap.org/replication/hour/
- THREADS=10
- OSM2PGSQL_EXTRA_ARGS=-C 8196
- ALLOW_CORS=enabled
- TILESIZE=512
volumes:
- osm-data:/data/database/
- osm-tiles:/data/tiles/
- ./run.sh:/run.sh
ports:
- "8080:80"
command: "run"
shm_size: 2g
volumes:
osm-tiles:
external: true
osm-data:
external: true

View File

@ -1,14 +0,0 @@
version: '3'
services:
map:
image: overv/openstreetmap-tile-server
volumes:
- osm-data:/data/database/
ports:
- "8080:80"
command: "run"
volumes:
osm-data:
external: true

View File

@ -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.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="" /> <link rel="stylesheet" href="leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script> <script src="leaflet.js"></script>
<style> <style>
html, body, #map { html, body, #map {

View File

@ -56,14 +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"}
REPLICATION_URL=${REPLICATION_URL:="https://planet.openstreetmap.org/replication/hour/"}
MAX_INTERVAL_SECONDS=${MAX_INTERVAL_SECONDS:="3600"}
#************************************************************************* #*************************************************************************
#************************************************************************* #*************************************************************************
@ -195,7 +191,7 @@ m_ok "expiring tiles"
# 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=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 if ! render_expired --map=default --min-zoom=$EXPIRY_MINZOOM --touch-from=$EXPIRY_TOUCHFROM --delete-from=$EXPIRY_DELETEFROM --max-zoom=$EXPIRY_MAXZOOM -s /run/renderd/renderd.sock < "$EXPIRY_FILE.$$" 2>&1 | tail -8 >> "$EXPIRYLOG"; then
m_info "Expiry failed" m_info "Expiry failed"
fi fi

View File

@ -1,7 +1,7 @@
# Suggested minimal settings from # Suggested minimal settings from
# https://ircama.github.io/osm-carto-tutorials/tile-server-ubuntu/ # https://ircama.github.io/osm-carto-tutorials/tile-server-ubuntu/
shared_buffers = 128MB shared_buffers = 1GB
min_wal_size = 1GB min_wal_size = 1GB
# max_wal_size = 2GB # Overridden below # max_wal_size = 2GB # Overridden below
maintenance_work_mem = 256MB maintenance_work_mem = 256MB
@ -16,10 +16,14 @@ wal_buffers = 1024kB
wal_writer_delay = 500ms wal_writer_delay = 500ms
commit_delay = 10000 commit_delay = 10000
# checkpoint_segments = 60 # unrecognized in psql 10.7.1 # checkpoint_segments = 60 # unrecognized in psql 10.7.1
max_wal_size = 2880MB max_wal_size = 5GB
random_page_cost = 1.1 random_page_cost = 1.1
track_activity_query_size = 16384 track_activity_query_size = 16384
autovacuum_vacuum_scale_factor = 0.05 autovacuum_vacuum_scale_factor = 0.05
autovacuum_analyze_scale_factor = 0.02 autovacuum_analyze_scale_factor = 0.02
checkpoint_timeout = 60min
wal_level = minimal
max_wal_senders = 0
listen_addresses = '*' listen_addresses = '*'

15
run.sh
View File

@ -3,9 +3,9 @@
set -euo pipefail set -euo pipefail
function createPostgresConfig() { function createPostgresConfig() {
cp /etc/postgresql/14/main/postgresql.custom.conf.tmpl /etc/postgresql/14/main/conf.d/postgresql.custom.conf cp /etc/postgresql/$PG_VERSION/main/postgresql.custom.conf.tmpl /etc/postgresql/$PG_VERSION/main/conf.d/postgresql.custom.conf
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/14/main/conf.d/postgresql.custom.conf sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/$PG_VERSION/main/conf.d/postgresql.custom.conf
cat /etc/postgresql/14/main/conf.d/postgresql.custom.conf cat /etc/postgresql/$PG_VERSION/main/conf.d/postgresql.custom.conf
} }
function setPostgresPassword() { function setPostgresPassword() {
@ -46,7 +46,7 @@ if [ "$1" == "import" ]; then
chown renderer: /data/database/ chown renderer: /data/database/
chown -R postgres: /var/lib/postgresql /data/database/postgres/ chown -R postgres: /var/lib/postgresql /data/database/postgres/
if [ ! -f /data/database/postgres/PG_VERSION ]; then if [ ! -f /data/database/postgres/PG_VERSION ]; then
sudo -u postgres /usr/lib/postgresql/14/bin/pg_ctl -D /data/database/postgres/ initdb -o "--locale C.UTF-8" sudo -u postgres /usr/lib/postgresql/$PG_VERSION/bin/pg_ctl -D /data/database/postgres/ initdb -o "--locale C.UTF-8"
fi fi
# Initialize PostgreSQL # Initialize PostgreSQL
@ -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 -d "=" -f 2` 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
@ -169,6 +169,7 @@ if [ "$1" == "run" ]; then
# Configure renderd threads # Configure renderd threads
sed -i -E "s/num_threads=[0-9]+/num_threads=${THREADS:-4}/g" /etc/renderd.conf sed -i -E "s/num_threads=[0-9]+/num_threads=${THREADS:-4}/g" /etc/renderd.conf
sed -i -E "s/TILESIZE=[0-9]+/TILESIZE=${TILESIZE:-256}/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
@ -197,3 +198,5 @@ fi
echo "invalid command" echo "invalid command"
exit 1 exit 1