2018-05-08 20:43:34 +00:00
|
|
|
FROM ubuntu:18.04
|
|
|
|
|
|
|
|
# Based on
|
|
|
|
# https://switch2osm.org/manually-building-a-tile-server-18-04-lts/
|
|
|
|
|
2019-03-14 14:56:07 +00:00
|
|
|
# Set up environment
|
|
|
|
ENV TZ=UTC
|
2019-04-16 05:45:10 +00:00
|
|
|
ENV AUTOVACUUM=on
|
2019-06-13 13:39:04 +00:00
|
|
|
ENV UPDATES=disabled
|
2019-03-14 14:56:07 +00:00
|
|
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
|
|
|
2018-05-08 20:43:34 +00:00
|
|
|
# Install dependencies
|
2019-10-22 21:11:50 +00:00
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install wget gnupg2 lsb-core -y \
|
2019-10-14 21:40:49 +00:00
|
|
|
&& 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 \
|
2019-03-15 15:50:46 +00:00
|
|
|
&& apt-get update \
|
2019-03-17 19:33:06 +00:00
|
|
|
&& apt-get install -y apt-transport-https ca-certificates \
|
2019-03-15 15:50:46 +00:00
|
|
|
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
|
2019-03-14 14:45:25 +00:00
|
|
|
apache2 \
|
|
|
|
apache2-dev \
|
|
|
|
autoconf \
|
|
|
|
build-essential \
|
|
|
|
bzip2 \
|
|
|
|
cmake \
|
2019-12-21 21:19:12 +00:00
|
|
|
cron \
|
2019-03-14 14:45:25 +00:00
|
|
|
fonts-noto-cjk \
|
|
|
|
fonts-noto-hinted \
|
|
|
|
fonts-noto-unhinted \
|
2019-10-14 21:40:49 +00:00
|
|
|
gcc \
|
2019-03-14 14:45:25 +00:00
|
|
|
gdal-bin \
|
|
|
|
git-core \
|
|
|
|
libagg-dev \
|
|
|
|
libboost-all-dev \
|
|
|
|
libbz2-dev \
|
|
|
|
libcairo-dev \
|
|
|
|
libcairomm-1.0-dev \
|
|
|
|
libexpat1-dev \
|
|
|
|
libfreetype6-dev \
|
|
|
|
libgdal-dev \
|
|
|
|
libgeos++-dev \
|
|
|
|
libgeos-dev \
|
|
|
|
libgeotiff-epsg \
|
|
|
|
libicu-dev \
|
2019-03-15 15:50:46 +00:00
|
|
|
liblua5.3-dev \
|
2019-03-14 14:45:25 +00:00
|
|
|
libmapnik-dev \
|
|
|
|
libpq-dev \
|
|
|
|
libproj-dev \
|
|
|
|
libprotobuf-c0-dev \
|
|
|
|
libtiff5-dev \
|
|
|
|
libtool \
|
|
|
|
libxml2-dev \
|
2019-03-15 15:50:46 +00:00
|
|
|
lua5.3 \
|
2019-03-14 14:45:25 +00:00
|
|
|
make \
|
|
|
|
mapnik-utils \
|
|
|
|
nodejs \
|
|
|
|
npm \
|
2019-12-21 21:19:12 +00:00
|
|
|
osmium-tool \
|
|
|
|
osmosis \
|
2019-03-14 14:45:25 +00:00
|
|
|
postgis \
|
2019-10-14 21:40:49 +00:00
|
|
|
postgresql-12 \
|
|
|
|
postgresql-contrib-12 \
|
2019-12-21 21:19:12 +00:00
|
|
|
postgresql-server-dev-12 \
|
2019-03-14 14:45:25 +00:00
|
|
|
protobuf-c-compiler \
|
2019-12-22 23:17:07 +00:00
|
|
|
python3-mapnik \
|
2019-12-21 21:19:12 +00:00
|
|
|
python3-lxml \
|
|
|
|
python3-psycopg2 \
|
|
|
|
python3-shapely \
|
2019-03-14 14:45:25 +00:00
|
|
|
sudo \
|
|
|
|
tar \
|
|
|
|
ttf-unifont \
|
|
|
|
unzip \
|
|
|
|
wget \
|
2019-03-15 15:50:46 +00:00
|
|
|
zlib1g-dev \
|
|
|
|
&& apt-get clean autoclean \
|
|
|
|
&& apt-get autoremove --yes \
|
|
|
|
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
|
2018-05-08 20:43:34 +00:00
|
|
|
|
2019-10-14 21:40:49 +00:00
|
|
|
# Set up PostGIS
|
2019-12-21 21:20:35 +00:00
|
|
|
RUN wget http://download.osgeo.org/postgis/source/postgis-3.0.0rc2.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
|
2019-10-14 21:40:49 +00:00
|
|
|
|
2019-03-14 14:56:07 +00:00
|
|
|
# Set up renderer user
|
2018-05-08 20:43:34 +00:00
|
|
|
RUN adduser --disabled-password --gecos "" renderer
|
|
|
|
|
|
|
|
# Install latest osm2pgsql
|
2019-12-21 21:25:04 +00:00
|
|
|
RUN mkdir -p /home/renderer/src \
|
|
|
|
&& cd /home/renderer/src \
|
|
|
|
&& git clone https://github.com/openstreetmap/osm2pgsql.git \
|
|
|
|
&& cd /home/renderer/src/osm2pgsql \
|
|
|
|
&& mkdir build \
|
|
|
|
&& cd build \
|
|
|
|
&& cmake .. \
|
|
|
|
&& make -j $(nproc) \
|
|
|
|
&& make install \
|
|
|
|
&& mkdir /nodes \
|
|
|
|
&& chown renderer:renderer /nodes \
|
|
|
|
&& rm -rf /home/renderer/src
|
2018-05-08 20:43:34 +00:00
|
|
|
|
|
|
|
# Install mod_tile and renderd
|
2019-12-21 21:26:30 +00:00
|
|
|
RUN mkdir -p /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 .. \
|
|
|
|
&& rm -rf mod_tile
|
2018-05-08 20:43:34 +00:00
|
|
|
|
|
|
|
# Configure stylesheet
|
2019-12-21 21:27:02 +00:00
|
|
|
RUN mkdir -p /home/renderer/src \
|
|
|
|
&& git clone https://github.com/gravitystorm/openstreetmap-carto.git \
|
|
|
|
&& git -C openstreetmap-carto checkout v4.23.0 \
|
2019-12-21 21:53:12 +00:00
|
|
|
&& cd openstreetmap-carto \
|
2019-12-22 20:48:33 +00:00
|
|
|
&& rm -rf .git \
|
2019-12-21 21:53:12 +00:00
|
|
|
&& npm install -g carto@0.18.2 \
|
|
|
|
&& carto project.mml > mapnik.xml \
|
|
|
|
&& scripts/get-shapefiles.py
|
2018-05-08 20:43:34 +00:00
|
|
|
|
|
|
|
# Configure renderd
|
2019-03-15 15:50:46 +00:00
|
|
|
RUN sed -i 's/renderaccount/renderer/g' /usr/local/etc/renderd.conf \
|
2019-12-21 21:53:12 +00:00
|
|
|
&& sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf
|
2018-05-08 20:43:34 +00:00
|
|
|
|
|
|
|
# Configure Apache
|
2019-03-15 15:50:46 +00:00
|
|
|
RUN mkdir /var/lib/mod_tile \
|
2019-12-21 21:33:56 +00:00
|
|
|
&& 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
|
2018-05-08 20:43:34 +00:00
|
|
|
COPY apache.conf /etc/apache2/sites-available/000-default.conf
|
2019-01-11 19:37:31 +00:00
|
|
|
COPY leaflet-demo.html /var/www/html/index.html
|
2019-09-17 20:03:03 +00:00
|
|
|
RUN ln -sf /dev/stdout /var/log/apache2/access.log \
|
2019-12-22 20:21:56 +00:00
|
|
|
&& ln -sf /dev/stderr /var/log/apache2/error.log
|
2019-01-11 19:37:31 +00:00
|
|
|
|
2019-03-15 17:33:40 +00:00
|
|
|
# Configure PosgtreSQL
|
2019-10-22 21:11:50 +00:00
|
|
|
COPY postgresql.custom.conf.tmpl /etc/postgresql/12/main/
|
2019-03-15 18:20:59 +00:00
|
|
|
RUN chown -R postgres:postgres /var/lib/postgresql \
|
2019-12-21 21:34:30 +00:00
|
|
|
&& 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
|
2019-03-15 17:33:40 +00:00
|
|
|
|
2019-12-22 20:21:56 +00:00
|
|
|
# Copy update scripts
|
2019-06-13 13:39:04 +00:00
|
|
|
COPY openstreetmap-tiles-update-expire /usr/bin/
|
|
|
|
RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \
|
2019-12-21 21:37:32 +00:00
|
|
|
&& 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
|
2019-06-13 13:39:04 +00:00
|
|
|
|
2019-12-22 20:21:56 +00:00
|
|
|
# Install trim_osc.py helper script
|
2019-12-21 22:09:37 +00:00
|
|
|
RUN mkdir -p /home/renderer/src \
|
|
|
|
&& cd /home/renderer/src \
|
2019-12-21 21:37:45 +00:00
|
|
|
&& git clone https://github.com/zverik/regional \
|
|
|
|
&& cd regional \
|
|
|
|
&& git checkout 612fe3e040d8bb70d2ab3b133f3b2cfc6c940520 \
|
2019-12-22 20:21:56 +00:00
|
|
|
&& rm -rf .git \
|
2019-12-21 22:09:37 +00:00
|
|
|
&& chmod u+x /home/renderer/src/regional/trim_osc.py
|
2019-06-13 13:39:04 +00:00
|
|
|
|
2018-05-08 20:43:34 +00:00
|
|
|
# Start running
|
|
|
|
COPY run.sh /
|
2019-06-14 21:23:42 +00:00
|
|
|
COPY indexes.sql /
|
2018-05-08 20:43:34 +00:00
|
|
|
ENTRYPOINT ["/run.sh"]
|
2019-01-11 19:37:31 +00:00
|
|
|
CMD []
|
2019-03-14 10:52:16 +00:00
|
|
|
|
|
|
|
EXPOSE 80 5432
|