Merge pull request #98 from Gjacquenot/master

Add CI for openstreetmap-tile-server
This commit is contained in:
Alexander Overvoorde 2019-12-27 14:52:46 +01:00 committed by GitHub
commit ac609febcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 118 additions and 83 deletions

30
.travis.yml Normal file
View File

@ -0,0 +1,30 @@
os: linux
language: minimal
services:
- docker
env:
global:
- DOCKER_USERNAME=gjacquenot
- secure: NvtIgByN0GmaSqNsTWFtAU8hKhtBqkScSkYMzlwImZaPa5aDfDyach/otae6Zp3dgWmlGR90ui5HrA+4V0DUvrdx3gODyycwzqF2CvoYtOPr6DC1SN5+xb1ty3toBKMlAJyXQRvwSO0oMkOvFRutC8HVBU8A6g+pO4+4pjpu4WfNLBBfWX5Gq4lVlOLZ4L5NH4Es+BNpdNNWVjZPkrdbU3UtjQIfV2bmAF9ws8GTSxi9+DfJT7Zmj4o9aZfAyfnZ8bdRdiEXUcn8Ilbk3rJwbxIq6IPfI0MmqKveHzpYjBrhQhEsr5cLdbhRI4zB235L+l/hzQDrld7+lVGWsZs60Pgw1xeFHH63J5kBT4Ibn3KOdMLyfEQqY2W3aODp3eU7Bkj/8J/s6rc+uBohGyJOM9muTL54OSfNDSb8q4M9Y4S9okSysZuuS6ry/sFn2kMasDYVYeOg+A9XscLj1JXGRL8/hImUuhRbWnyob1F+gbpH1lbgWIAtQ97bHWt4xJs+Fps4LdaXeUZNTb+FIXE9RRe+qbbHX4+ExIkrkFg3JUnmaS37J8XZJmVXw3panv2DuGV2ri1u1DCa1/JpPmB6AbQIL1jfC7FmuqgMbRGg/6U2h5kAAga8gbyEZscMA1DyFhsqgIG/k87oqRiUumvJ9+/m+o9/EV+XvDLjgHzGMvA=
before_install:
- echo "Before install"
before_script:
- docker pull gjacquenot/openstreetmap-tile-server || true
script:
- docker build --pull --cache-from gjacquenot/openstreetmap-tile-server --tag gjacquenot/openstreetmap-tile-server .
- docker volume create openstreetmap-data
- docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main gjacquenot/openstreetmap-tile-server import
- docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main -p 80:80 -d gjacquenot/openstreetmap-tile-server run
- sleep 30
- make DOCKER_IMAGE=gjacquenot/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 gjacquenot/openstreetmap-tile-server ;
fi
notifications:
email: true

View File

@ -23,16 +23,16 @@ RUN apt-get update \
build-essential \ build-essential \
bzip2 \ bzip2 \
cmake \ cmake \
cron \
fonts-noto-cjk \ fonts-noto-cjk \
fonts-noto-hinted \ fonts-noto-hinted \
fonts-noto-unhinted \ fonts-noto-unhinted \
clang \
gcc \ gcc \
gdal-bin \ gdal-bin \
make \
git-core \ git-core \
libagg-dev \ libagg-dev \
libboost-all-dev \ libboost-filesystem-dev \
libboost-system-dev \
libbz2-dev \ libbz2-dev \
libcairo-dev \ libcairo-dev \
libcairomm-1.0-dev \ libcairomm-1.0-dev \
@ -56,93 +56,88 @@ RUN apt-get update \
mapnik-utils \ mapnik-utils \
nodejs \ nodejs \
npm \ npm \
osmium-tool \
osmosis \
postgis \ postgis \
postgresql-12 \ postgresql-12 \
postgresql-server-dev-12 \
postgresql-contrib-12 \ postgresql-contrib-12 \
postgresql-server-dev-12 \
protobuf-c-compiler \ protobuf-c-compiler \
python-mapnik \ python3-mapnik \
python3-lxml \
python3-psycopg2 \
python3-shapely \
sudo \ sudo \
tar \ tar \
ttf-unifont \ ttf-unifont \
unzip \ unzip \
wget \ wget \
zlib1g-dev \ zlib1g-dev \
osmosis \
osmium-tool \
cron \
python3-psycopg2 python3-shapely python3-lxml \
&& apt-get clean autoclean \ && apt-get clean autoclean \
&& apt-get autoremove --yes \ && apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ && rm -rf /var/lib/{apt,dpkg,cache,log}/
# Set up PostGIS # Set up PostGIS
RUN wget http://download.osgeo.org/postgis/source/postgis-3.0.0rc2.tar.gz RUN wget http://download.osgeo.org/postgis/source/postgis-3.0.0.tar.gz -O postgis.tar.gz \
RUN tar -xvzf postgis-3.0.0rc2.tar.gz && mkdir -p postgis_src \
RUN cd postgis-3.0.0rc2 && ./configure && make && make install && 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 # Set up renderer user
RUN adduser --disabled-password --gecos "" renderer RUN adduser --disabled-password --gecos "" renderer
USER renderer
# Install latest osm2pgsql # Install latest osm2pgsql
RUN mkdir /home/renderer/src RUN mkdir -p /home/renderer/src \
WORKDIR /home/renderer/src && cd /home/renderer/src \
RUN git clone https://github.com/openstreetmap/osm2pgsql.git && git clone https://github.com/openstreetmap/osm2pgsql.git \
WORKDIR /home/renderer/src/osm2pgsql && cd /home/renderer/src/osm2pgsql \
RUN mkdir build && rm -rf .git \
WORKDIR /home/renderer/src/osm2pgsql/build && mkdir build \
RUN cmake .. \ && cd build \
&& make -j $(nproc) && cmake .. \
USER root && make -j $(nproc) \
RUN make install && make install \
RUN mkdir /nodes \ && mkdir /nodes \
&& chown renderer:renderer /nodes && chown renderer:renderer /nodes \
USER renderer && rm -rf /home/renderer/src/osm2pgsql
# Install and test Mapnik
RUN python -c 'import mapnik'
# Install mod_tile and renderd # Install mod_tile and renderd
WORKDIR /home/renderer/src RUN mkdir -p /home/renderer/src \
RUN git clone -b switch2osm https://github.com/SomeoneElseOSM/mod_tile.git && cd /home/renderer/src \
WORKDIR /home/renderer/src/mod_tile && git clone -b switch2osm https://github.com/SomeoneElseOSM/mod_tile.git \
RUN ./autogen.sh \ && cd mod_tile \
&& ./autogen.sh \
&& ./configure \ && ./configure \
&& make -j $(nproc) && make -j $(nproc) \
USER root && make -j $(nproc) install \
RUN make -j $(nproc) install \
&& make -j $(nproc) install-mod_tile \ && make -j $(nproc) install-mod_tile \
&& ldconfig && ldconfig \
USER renderer && cd ..
# Configure stylesheet # Configure stylesheet
WORKDIR /home/renderer/src RUN mkdir -p /home/renderer/src \
RUN git clone https://github.com/gravitystorm/openstreetmap-carto.git \ && cd /home/renderer/src \
&& git -C openstreetmap-carto checkout v4.23.0 && git clone https://github.com/gravitystorm/openstreetmap-carto.git \
WORKDIR /home/renderer/src/openstreetmap-carto && git -C openstreetmap-carto checkout v4.23.0 \
USER root && cd openstreetmap-carto \
RUN npm install -g carto@0.18.2 && rm -rf .git \
USER renderer && npm install -g carto@0.18.2 \
RUN carto project.mml > mapnik.xml && carto project.mml > mapnik.xml \
&& scripts/get-shapefiles.py
# Load shapefiles
WORKDIR /home/renderer/src/openstreetmap-carto
RUN scripts/get-shapefiles.py
# Configure renderd # Configure renderd
USER root
RUN sed -i 's/renderaccount/renderer/g' /usr/local/etc/renderd.conf \ RUN sed -i 's/renderaccount/renderer/g' /usr/local/etc/renderd.conf \
&& sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf && sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf
USER renderer
# Configure Apache # Configure Apache
USER root
RUN mkdir /var/lib/mod_tile \ RUN mkdir /var/lib/mod_tile \
&& chown renderer /var/lib/mod_tile \ && chown renderer /var/lib/mod_tile \
&& mkdir /var/run/renderd \ && mkdir /var/run/renderd \
&& chown renderer /var/run/renderd && chown renderer /var/run/renderd \
RUN echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \ && echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \
&& echo "LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so" >> /etc/apache2/conf-available/mod_headers.conf \ && echo "LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so" >> /etc/apache2/conf-available/mod_headers.conf \
&& a2enconf mod_tile && a2enconf mod_headers && a2enconf mod_tile && a2enconf mod_headers
COPY apache.conf /etc/apache2/sites-available/000-default.conf COPY apache.conf /etc/apache2/sites-available/000-default.conf
@ -153,11 +148,11 @@ RUN ln -sf /dev/stdout /var/log/apache2/access.log \
# Configure PosgtreSQL # Configure PosgtreSQL
COPY postgresql.custom.conf.tmpl /etc/postgresql/12/main/ COPY postgresql.custom.conf.tmpl /etc/postgresql/12/main/
RUN chown -R postgres:postgres /var/lib/postgresql \ RUN chown -R postgres:postgres /var/lib/postgresql \
&& chown postgres:postgres /etc/postgresql/12/main/postgresql.custom.conf.tmpl && chown postgres:postgres /etc/postgresql/12/main/postgresql.custom.conf.tmpl \
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/12/main/pg_hba.conf \ && 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 && 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 /usr/bin/
RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \ RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \
&& mkdir /var/log/tiles \ && mkdir /var/log/tiles \
@ -165,16 +160,16 @@ RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \
&& ln -s /home/renderer/src/mod_tile/osmosis-db_replag /usr/bin/osmosis-db_replag \ && ln -s /home/renderer/src/mod_tile/osmosis-db_replag /usr/bin/osmosis-db_replag \
&& echo "* * * * * renderer openstreetmap-tiles-update-expire\n" >> /etc/crontab && echo "* * * * * renderer openstreetmap-tiles-update-expire\n" >> /etc/crontab
# install trim_osc.py helper script # Install trim_osc.py helper script
USER renderer RUN mkdir -p /home/renderer/src \
RUN cd ~/src \ && cd /home/renderer/src \
&& git clone https://github.com/zverik/regional \ && git clone https://github.com/zverik/regional \
&& cd regional \ && cd regional \
&& git checkout 612fe3e040d8bb70d2ab3b133f3b2cfc6c940520 \ && git checkout 612fe3e040d8bb70d2ab3b133f3b2cfc6c940520 \
&& chmod u+x ~/src/regional/trim_osc.py && rm -rf .git \
&& chmod u+x /home/renderer/src/regional/trim_osc.py
# Start running # Start running
USER root
COPY run.sh / COPY run.sh /
COPY indexes.sql / COPY indexes.sql /
ENTRYPOINT ["/run.sh"] ENTRYPOINT ["/run.sh"]

View File

@ -1,12 +1,18 @@
.PHONY: build push test .PHONY: build push test
DOCKER_IMAGE=overv/openstreetmap-tile-server
build: build:
docker build -t overv/openstreetmap-tile-server . docker build -t ${DOCKER_IMAGE} .
push: build push: build
docker push overv/openstreetmap-tile-server:latest docker push ${DOCKER_IMAGE}:latest
test: build test: build
docker volume create openstreetmap-data docker volume create openstreetmap-data
docker run -v openstreetmap-data:/var/lib/postgresql/12/main overv/openstreetmap-tile-server import docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main ${DOCKER_IMAGE} import
docker run -v openstreetmap-data:/var/lib/postgresql/12/main -p 80:80 -d overv/openstreetmap-tile-server run docker run --rm -v openstreetmap-data:/var/lib/postgresql/12/main -p 80: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,9 @@
# openstreetmap-tile-server # openstreetmap-tile-server
[![Build Status](https://travis-ci.org/Gjacquenot/openstreetmap-tile-server.svg?branch=master)](https://travis-ci.org/Gjacquenot/openstreetmap-tile-server)
[![](https://images.microbadger.com/badges/image/gjacquenot/openstreetmap-tile-server.svg)](https://microbadger.com/images/gjacquenot/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. 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 ## Setting up the server