Compare commits

...

46 Commits

Author SHA1 Message Date
Alexander Overvoorde
5a1b2a6b06 Add support for host mounts (fixes #94) 2020-02-19 21:04:24 +01:00
Alexander Overvoorde
5300472417 Accept both the values enabled and 1 for boolean flags for backwards compatibility 2020-02-12 20:18:19 +01:00
Alexander Overvoorde
f9a29fb23b Merge pull request #104 from darekzbik/cors_property
fix configuration values inconsistency
2020-02-12 20:18:06 +01:00
Dariusz Zbik
52c89b4775 fix configuration values inconsistency 2020-02-10 22:24:34 +01:00
Alexander Overvoorde
0bb62b77d3 Merge pull request #101 from pandel/master
Get nodejs from source because of apt package conflict
2020-02-10 22:09:50 +01:00
Holger Pandel
0a5ac2a018 Get nodejs from source 2020-02-09 21:13:22 +01:00
Alexander Overvoorde
f0f36a6c9b Merge pull request #99 from irexiz/master
Remove unnecessary shapefile archives to reduce final image size
2020-02-04 19:58:55 +01:00
irekzagan
b192fabac3 remove unnecessary shapefile archives 2020-01-23 16:25:24 +01:00
Alexander Overvoorde
f2971fa97e Fix badge URL some more and change badge layout 2019-12-27 15:07:05 +01:00
Alexander Overvoorde
0d789b883d Fix Docker badge URL and update ports in test code 2019-12-27 15:04:21 +01:00
Alexander Overvoorde
99484a505b Update Travis config 2019-12-27 14:58:56 +01:00
Alexander Overvoorde
ac609febcc Merge pull request #98 from Gjacquenot/master
Add CI for openstreetmap-tile-server
2019-12-27 14:52:46 +01:00
Guillaume Jacquenot
dafb4610cd 🐛 Fixed removed symbolic link 2019-12-25 21:49:31 +01:00
Guillaume Jacquenot
a90f8f1d8c 🔧 Updated .travis.yml 2019-12-24 00:02:49 +01:00
Guillaume Jacquenot
515dd2a18c 🔧 Updated .travis.yml 2019-12-23 23:36:30 +01:00
Guillaume Jacquenot
18c97f52bf 🔨 Updated .travis.yml 2019-12-23 23:10:33 +01:00
Guillaume Jacquenot
e9a26ddded 🔨 Updated .travis.yml 2019-12-23 22:47:53 +01:00
Guillaume Jacquenot
d0428523b5 🔧 Switched from postgis-3.0.0rc2 to postgis-3.0.0 2019-12-23 22:08:41 +01:00
Guillaume Jacquenot
4ca2e8f1e5 🔧 Removed build directory /home/renderer/src/osm2pgsql 2019-12-23 22:07:06 +01:00
Guillaume Jacquenot
17a2c6d631 🔧 Removed boost libraries 2019-12-23 21:51:41 +01:00
Guillaume Jacquenot
d7922429f3 Added badges in main Readme.md 2019-12-23 21:38:20 +01:00
Guillaume Jacquenot
837a38df04 🐛 Fixed remove directory /home/renderer/src 2019-12-23 21:38:20 +01:00
Guillaume Jacquenot
f69bcd2540 🔨 Switched from python-mapnik -> python3-mapnik 2019-12-23 21:38:20 +01:00
Guillaume Jacquenot
f77c926ee5 🔧 Tag docker image so that it can be pushed to dockerhub 2019-12-23 21:38:20 +01:00
Guillaume Jacquenot
bae840f240 🔧 Added sleep command before we stop everything 2019-12-23 21:38:20 +01:00
Guillaume Jacquenot
e0f7438dab 🔨 Updated Makefile 2019-12-23 21:35:45 +01:00
Guillaume Jacquenot
637e821888 🔨 Removed .git directory 2019-12-23 21:35:45 +01:00
Guillaume Jacquenot
e8e95c6001 🔨 Refactored Dockerfile 2019-12-23 21:35:45 +01:00
Guillaume Jacquenot
d8ccc2c026 🔧 Removed clang 2019-12-23 21:35:45 +01:00
Guillaume Jacquenot
b71e7a6aba 🔨 Refactored regional instruction 2019-12-23 21:35:45 +01:00
Guillaume Jacquenot
62a972736a 🔨 Updated user command 2019-12-23 21:35:45 +01:00
Guillaume Jacquenot
f9f1047400 📝 Updated .travis.yml 2019-12-23 21:35:45 +01:00
Guillaume Jacquenot
fa4b0eba0b 📝 Typo update 2019-12-22 21:01:18 +01:00
Guillaume Jacquenot
69cb804609 📝 Typo update 2019-12-22 21:01:18 +01:00
Guillaume Jacquenot
efc2cb1e2a 🔨 Refactored PosgtreSQL install 2019-12-22 21:01:18 +01:00
Guillaume Jacquenot
6de21a4595 🔨 Refactored PosgtreSQL install 2019-12-22 21:01:18 +01:00
Guillaume Jacquenot
868d2fae0a 🔨 Refactored openstreetmap-carto install 2019-12-22 21:01:18 +01:00
Guillaume Jacquenot
0527120c30 🔨 Refactored mod_tile install 2019-12-22 21:01:18 +01:00
Guillaume Jacquenot
8bac516eb1 🔨 Refactored osm2pgsql install 2019-12-22 21:01:18 +01:00
Guillaume Jacquenot
c8a79a19e4 🔨 Refactored PostGIS install 2019-12-22 21:01:18 +01:00
Guillaume Jacquenot
92708df534 🔨 Reorder ubuntu packages 2019-12-22 21:01:18 +01:00
Guillaume Jacquenot
879e5f25ab Create .travis.yml 2019-12-22 21:01:18 +01:00
Alexander Overvoorde
010f87d711 Change example server port to 8080 and include Docker Compose example 2019-12-22 13:53:12 +01:00
Alexander Overvoorde
789ff772be Change custom config to be overridable 2019-12-05 21:27:46 +01:00
Alexander Overvoorde
64c66a7d0b Make setup for automatic updates optional through UPDATES variable 2019-11-07 21:12:29 +01:00
Alexander Overvoorde
626158f677 Fix remaining references to PostgreSQL 10 2019-10-22 23:11:50 +02:00
6 changed files with 180 additions and 118 deletions

28
.travis.yml Normal file
View File

@@ -0,0 +1,28 @@
os: linux
language: minimal
services:
- docker
# DOCKER_USERNAME/DOCKER_PASSWORD have been configured in Travis CI
# env:
before_install:
- echo "Before install"
before_script:
- docker pull overv/openstreetmap-tile-server || true
script:
- docker build --pull --cache-from overv/openstreetmap-tile-server --tag overv/openstreetmap-tile-server .
- docker volume create openstreetmap-data
- docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main overv/openstreetmap-tile-server import
- docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main -p 8080:80 -d overv/openstreetmap-tile-server run
- sleep 30
- make DOCKER_IMAGE=overv/openstreetmap-tile-server stop
after_script:
- docker images
after_success:
- if [[ "$TRAVIS_BRANCH" == "master" ]];
then
docker images ;
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ;
docker push overv/openstreetmap-tile-server ;
fi
notifications:
email: true

View File

@@ -10,29 +10,34 @@ ENV UPDATES=disabled
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install dependencies
RUN apt-get update \
&& apt-get install wget gnupg2 lsb-core -y \
RUN apt-get update \
&& apt-get install wget gnupg2 lsb-core -y \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb [ trusted=yes ] http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y apt-transport-https ca-certificates \
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
&& apt-get install -y apt-transport-https ca-certificates
RUN apt-get install -y curl \
&& wget --quiet -O - https://deb.nodesource.com/setup_10.x | bash - \
&& apt-get install -y nodejs
RUN apt-get install -y --no-install-recommends --allow-unauthenticated \
apache2 \
apache2-dev \
autoconf \
build-essential \
bzip2 \
cmake \
cron \
fonts-noto-cjk \
fonts-noto-hinted \
fonts-noto-unhinted \
clang \
gcc \
gdal-bin \
make \
git-core \
libagg-dev \
libboost-all-dev \
libboost-filesystem-dev \
libboost-system-dev \
libbz2-dev \
libcairo-dev \
libcairomm-1.0-dev \
@@ -54,128 +59,122 @@ RUN apt-get update \
lua5.3 \
make \
mapnik-utils \
nodejs \
npm \
node-gyp \
osmium-tool \
osmosis \
postgis \
postgresql-12 \
postgresql-server-dev-12 \
postgresql-contrib-12 \
postgresql-server-dev-12 \
protobuf-c-compiler \
python-mapnik \
python3-mapnik \
python3-lxml \
python3-psycopg2 \
python3-shapely \
sudo \
tar \
ttf-unifont \
unzip \
wget \
zlib1g-dev \
osmosis \
osmium-tool \
cron \
python3-psycopg2 python3-shapely python3-lxml \
&& apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
# Set up PostGIS
RUN wget http://download.osgeo.org/postgis/source/postgis-3.0.0rc2.tar.gz
RUN tar -xvzf postgis-3.0.0rc2.tar.gz
RUN cd postgis-3.0.0rc2 && ./configure && make && make install
RUN wget http://download.osgeo.org/postgis/source/postgis-3.0.0.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 && make install \
&& cd .. && rm -rf postgis_src
# Set up renderer user
RUN adduser --disabled-password --gecos "" renderer
USER renderer
# Install latest osm2pgsql
RUN mkdir /home/renderer/src
WORKDIR /home/renderer/src
RUN git clone https://github.com/openstreetmap/osm2pgsql.git
WORKDIR /home/renderer/src/osm2pgsql
RUN mkdir build
WORKDIR /home/renderer/src/osm2pgsql/build
RUN cmake .. \
&& make -j $(nproc)
USER root
RUN make install
RUN mkdir /nodes \
&& chown renderer:renderer /nodes
USER renderer
# Install and test Mapnik
RUN python -c 'import mapnik'
RUN mkdir -p /home/renderer/src \
&& cd /home/renderer/src \
&& git clone https://github.com/openstreetmap/osm2pgsql.git \
&& cd /home/renderer/src/osm2pgsql \
&& rm -rf .git \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make -j $(nproc) \
&& make install \
&& mkdir /nodes \
&& chown renderer:renderer /nodes \
&& rm -rf /home/renderer/src/osm2pgsql
# Install mod_tile and renderd
WORKDIR /home/renderer/src
RUN git clone -b switch2osm https://github.com/SomeoneElseOSM/mod_tile.git
WORKDIR /home/renderer/src/mod_tile
RUN ./autogen.sh \
&& ./configure \
&& make -j $(nproc)
USER root
RUN make -j $(nproc) install \
&& make -j $(nproc) install-mod_tile \
&& ldconfig
USER renderer
RUN mkdir -p /home/renderer/src \
&& cd /home/renderer/src \
&& git clone -b switch2osm https://github.com/SomeoneElseOSM/mod_tile.git \
&& cd mod_tile \
&& ./autogen.sh \
&& ./configure \
&& make -j $(nproc) \
&& make -j $(nproc) install \
&& make -j $(nproc) install-mod_tile \
&& ldconfig \
&& cd ..
# Configure stylesheet
WORKDIR /home/renderer/src
RUN git clone https://github.com/gravitystorm/openstreetmap-carto.git \
&& git -C openstreetmap-carto checkout v4.23.0
WORKDIR /home/renderer/src/openstreetmap-carto
USER root
RUN npm install -g carto@0.18.2
USER renderer
RUN carto project.mml > mapnik.xml
# Load shapefiles
WORKDIR /home/renderer/src/openstreetmap-carto
RUN scripts/get-shapefiles.py
RUN mkdir -p /home/renderer/src \
&& cd /home/renderer/src \
&& git clone https://github.com/gravitystorm/openstreetmap-carto.git \
&& git -C openstreetmap-carto checkout v4.23.0 \
&& cd openstreetmap-carto \
&& rm -rf .git \
&& npm install -g carto@0.18.2 \
&& carto project.mml > mapnik.xml \
&& scripts/get-shapefiles.py \
&& rm /home/renderer/src/openstreetmap-carto/data/*.zip
# Configure renderd
USER root
RUN sed -i 's/renderaccount/renderer/g' /usr/local/etc/renderd.conf \
&& sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf
USER renderer
&& sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf
# Configure Apache
USER root
RUN mkdir /var/lib/mod_tile \
&& chown renderer /var/lib/mod_tile \
&& mkdir /var/run/renderd \
&& chown renderer /var/run/renderd
RUN echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \
&& echo "LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so" >> /etc/apache2/conf-available/mod_headers.conf \
&& a2enconf mod_tile && a2enconf mod_headers
&& 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 \
&& a2enconf mod_tile && a2enconf mod_headers
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 \
&& 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/10/main/
COPY postgresql.custom.conf.tmpl /etc/postgresql/12/main/
RUN chown -R postgres:postgres /var/lib/postgresql \
&& chown postgres:postgres /etc/postgresql/10/main/postgresql.custom.conf.tmpl \
&& echo "\ninclude 'postgresql.custom.conf'" >> /etc/postgresql/10/main/postgresql.conf
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/10/main/pg_hba.conf \
&& echo "host all all ::/0 md5" >> /etc/postgresql/10/main/pg_hba.conf
&& 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/
RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \
&& mkdir /var/log/tiles \
&& chmod a+rw /var/log/tiles \
&& ln -s /home/renderer/src/mod_tile/osmosis-db_replag /usr/bin/osmosis-db_replag \
&& echo "* * * * * renderer openstreetmap-tiles-update-expire\n" >> /etc/crontab
&& mkdir /var/log/tiles \
&& chmod a+rw /var/log/tiles \
&& ln -s /home/renderer/src/mod_tile/osmosis-db_replag /usr/bin/osmosis-db_replag \
&& echo "* * * * * renderer openstreetmap-tiles-update-expire\n" >> /etc/crontab
# install trim_osc.py helper script
USER renderer
RUN cd ~/src \
&& git clone https://github.com/zverik/regional \
&& cd regional \
&& git checkout 612fe3e040d8bb70d2ab3b133f3b2cfc6c940520 \
&& chmod u+x ~/src/regional/trim_osc.py
# Install trim_osc.py helper script
RUN mkdir -p /home/renderer/src \
&& cd /home/renderer/src \
&& git clone https://github.com/zverik/regional \
&& cd regional \
&& git checkout 612fe3e040d8bb70d2ab3b133f3b2cfc6c940520 \
&& rm -rf .git \
&& chmod u+x /home/renderer/src/regional/trim_osc.py
# Start running
USER root
COPY run.sh /
COPY indexes.sql /
ENTRYPOINT ["/run.sh"]

View File

@@ -1,12 +1,18 @@
.PHONY: build push test
DOCKER_IMAGE=overv/openstreetmap-tile-server
build:
docker build -t overv/openstreetmap-tile-server .
docker build -t ${DOCKER_IMAGE} .
push: build
docker push overv/openstreetmap-tile-server:latest
docker push ${DOCKER_IMAGE}:latest
test: build
docker volume create openstreetmap-data
docker run -v openstreetmap-data:/var/lib/postgresql/12/main overv/openstreetmap-tile-server import
docker run -v openstreetmap-data:/var/lib/postgresql/12/main -p 80:80 -d overv/openstreetmap-tile-server run
docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main ${DOCKER_IMAGE} import
docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main -p 8080:80 -d ${DOCKER_IMAGE} run
stop:
docker rm -f `docker ps | grep '${DOCKER_IMAGE}' | awk '{ print $$1 }'` || true
docker volume rm -f openstreetmap-data

View File

@@ -1,5 +1,7 @@
# openstreetmap-tile-server
[![Build Status](https://travis-ci.org/Overv/openstreetmap-tile-server.svg?branch=master)](https://travis-ci.org/Overv/openstreetmap-tile-server) [![](https://images.microbadger.com/badges/image/overv/openstreetmap-tile-server.svg)](https://microbadger.com/images/overv/openstreetmap-tile-server "openstreetmap-tile-server")
This container allows you to easily set up an OpenStreetMap PNG tile server given a `.osm.pbf` file. It is based on the [latest Ubuntu 18.04 LTS guide](https://switch2osm.org/manually-building-a-tile-server-18-04-lts/) from [switch2osm.org](https://switch2osm.org/) and therefore uses the default OpenStreetMap style.
## Setting up the server
@@ -22,10 +24,11 @@ If the container exits without errors, then your data has been successfully impo
### Automatic updates (optional)
If your import is an extract of the planet and has polygonal bounds associated with it, like those from geofabrik.de, then it is possible to set your server up for automatic updates. Make sure to reference both the OSM file and the polygon file during the import process to facilitate this:
If your import is an extract of the planet and has polygonal bounds associated with it, like those from geofabrik.de, then it is possible to set your server up for automatic updates. Make sure to reference both the OSM file and the polygon file during the import process to facilitate this, and also include the `UPDATES=enabled` variable:
```
docker run \
-e UPDATES=enabled \
-v /absolute/path/to/luxembourg.osm.pbf:/data.osm.pbf \
-v /absolute/path/to/luxembourg.poly:/data.poly \
-v openstreetmap-data:/var/lib/postgresql/12/main \
@@ -33,7 +36,7 @@ docker run \
import
```
Refer to the section *Automatic updating and tile expiry* to actually enable the updates.
Refer to the section *Automatic updating and tile expiry* to actually enable the updates while running the tile server.
## Running the server
@@ -41,13 +44,17 @@ Run the server like this:
```
docker run \
-p 80:80 \
-p 8080:80 \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-d overv/openstreetmap-tile-server \
run
```
Your tiles will now be available at `http://localhost:80/tile/{z}/{x}/{y}.png`. The demo map in `leaflet-demo.html` will then be available on `http://localhost:80`. Note that it will initially take quite a bit of time to render the larger tiles for the first time.
Your tiles will now be available at `http://localhost:8080/tile/{z}/{x}/{y}.png`. The demo map in `leaflet-demo.html` will then be available on `http://localhost:8080`. Note that it will initially take quite a bit of time to render the larger tiles for the first time.
### Using Docker Compose
The `docker-compose.yml` file included with this repository shows how the aforementioned command can be used with Docker Compose to run your server.
### Preserving rendered tiles
@@ -56,7 +63,7 @@ Tiles that have already been rendered will be stored in `/var/lib/mod_tile`. To
```
docker volume create openstreetmap-rendered-tiles
docker run \
-p 80:80 \
-p 8080:80 \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-v openstreetmap-rendered-tiles:/var/lib/mod_tile \
-d overv/openstreetmap-tile-server \
@@ -67,11 +74,11 @@ docker run \
### Enabling automatic updating (optional)
Given that you've specified both the OSM data and polygon as specified in the *Automatic updates* section during server setup, you can enable the updating process by setting the variable `UPDATES` to `enabled`:
Given that you've set up your import as described in the *Automatic updates* section during server setup, you can enable the updating process by setting the `UPDATES` variable while running your server as well:
```
docker run \
-p 80:80 \
-p 8080:80 \
-e UPDATES=enabled \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-v openstreetmap-rendered-tiles:/var/lib/mod_tile \
@@ -83,13 +90,13 @@ This will enable a background process that automatically downloads changes from
### Cross-origin resource sharing
To enable the `Access-Control-Allow-Origin` header to be able to retrieve tiles from other domains, simply set the `ALLOW_CORS` variable to `1`:
To enable the `Access-Control-Allow-Origin` header to be able to retrieve tiles from other domains, simply set the `ALLOW_CORS` variable to `enabled`:
```
docker run \
-p 80:80 \
-p 8080:80 \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-e ALLOW_CORS=1 \
-e ALLOW_CORS=enabled \
-d overv/openstreetmap-tile-server \
run
```
@@ -100,7 +107,7 @@ To connect to the PostgreSQL database inside the container, make sure to expose
```
docker run \
-p 80:80 \
-p 8080:80 \
-p 5432:5432 \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-d overv/openstreetmap-tile-server \
@@ -117,7 +124,7 @@ The default password is `renderer`, but it can be changed using the `PGPASSWORD`
```
docker run \
-p 80:80 \
-p 8080:80 \
-p 5432:5432 \
-e PGPASSWORD=secret \
-v openstreetmap-data:/var/lib/postgresql/12/main \
@@ -134,7 +141,7 @@ Details for update procedure and invoked scripts can be found here [link](https:
The import and tile serving processes use 4 threads by default, but this number can be changed by setting the `THREADS` environment variable. For example:
```
docker run \
-p 80:80 \
-p 8080:80 \
-e THREADS=24 \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-d overv/openstreetmap-tile-server \
@@ -146,7 +153,7 @@ docker run \
The import and tile serving processes use 800 MB RAM cache by default, but this number can be changed by option -C. For example:
```
docker run \
-p 80:80 \
-p 8080:80 \
-e "OSM2PGSQL_EXTRA_ARGS=-C 4096" \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-d overv/openstreetmap-tile-server \
@@ -158,7 +165,7 @@ docker run \
The database use the autovacuum feature by default. This behavior can be changed with `AUTOVACUUM` environment variable. For example:
```
docker run \
-p 80:80 \
-p 8080:80 \
-e AUTOVACUUM=off \
-v openstreetmap-data:/var/lib/postgresql/12/main \
-d overv/openstreetmap-tile-server \
@@ -197,7 +204,7 @@ renderd[121]: reason: Postgis Plugin: ERROR: could not resize shared memory segm
To raise it use `--shm-size` parameter. For example:
```
docker run \
-p 80:80 \
-p 8080:80 \
-v openstreetmap-data:/var/lib/postgresql/12/main \
--shm-size="192m" \
-d overv/openstreetmap-tile-server \

14
docker-compose.yml Normal file
View File

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

30
run.sh
View File

@@ -3,9 +3,9 @@
set -x
function createPostgresConfig() {
cp /etc/postgresql/12/main/postgresql.custom.conf.tmpl /etc/postgresql/12/main/postgresql.custom.conf
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/12/main/postgresql.custom.conf
cat /etc/postgresql/12/main/postgresql.custom.conf
cp /etc/postgresql/12/main/postgresql.custom.conf.tmpl /etc/postgresql/12/main/conf.d/postgresql.custom.conf
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/12/main/conf.d/postgresql.custom.conf
cat /etc/postgresql/12/main/conf.d/postgresql.custom.conf
}
function setPostgresPassword() {
@@ -24,6 +24,12 @@ if [ "$#" -ne 1 ]; then
fi
if [ "$1" = "import" ]; then
# Ensure that database directory is in right state
chown postgres:postgres -R /var/lib/postgresql
if [ ! -f /var/lib/postgresql/12/main/PG_VERSION ]; then
sudo -u postgres /usr/lib/postgresql/12/bin/pg_ctl -D /var/lib/postgresql/12/main/ initdb -o "--locale C.UTF-8"
fi
# Initialize PostgreSQL
createPostgresConfig
service postgresql start
@@ -42,13 +48,15 @@ if [ "$1" = "import" ]; then
wget -nv http://download.geofabrik.de/europe/luxembourg.poly -O /data.poly
fi
# determine and set osmosis_replication_timestamp (for consecutive updates)
osmium fileinfo /data.osm.pbf > /var/lib/mod_tile/data.osm.pbf.info
osmium fileinfo /data.osm.pbf | grep 'osmosis_replication_timestamp=' | cut -b35-44 > /var/lib/mod_tile/replication_timestamp.txt
REPLICATION_TIMESTAMP=$(cat /var/lib/mod_tile/replication_timestamp.txt)
if [ "$UPDATES" = "enabled" ]; then
# determine and set osmosis_replication_timestamp (for consecutive updates)
osmium fileinfo /data.osm.pbf > /var/lib/mod_tile/data.osm.pbf.info
osmium fileinfo /data.osm.pbf | 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)
sudo -u renderer openstreetmap-tiles-update-expire $REPLICATION_TIMESTAMP
# initial setup of osmosis workspace (for consecutive updates)
sudo -u renderer openstreetmap-tiles-update-expire $REPLICATION_TIMESTAMP
fi
# copy polygon file if available
if [ -f /data.poly ]; then
@@ -77,7 +85,7 @@ if [ "$1" = "run" ]; then
chown postgres:postgres /var/lib/postgresql -R
# Configure Apache CORS
if [ "$ALLOW_CORS" == "1" ]; then
if [ "$ALLOW_CORS" == "enabled" ] || [ "$ALLOW_CORS" == "1" ]; then
echo "export APACHE_ARGUMENTS='-D ALLOW_CORS'" >> /etc/apache2/envvars
fi
@@ -91,7 +99,7 @@ if [ "$1" = "run" ]; then
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
if [ "$UPDATES" = "enabled" ]; then
if [ "$UPDATES" = "enabled" ] || [ "$UPDATES" = "1" ]; then
/etc/init.d/cron start
fi