openstreetmap-tile-server/Dockerfile

168 lines
4.3 KiB
Docker
Raw Normal View History

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
ENV AUTOVACUUM=on
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-03-15 15:50:46 +00:00
RUN echo "deb [ allow-insecure=yes ] http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main" >> /etc/apt/sources.list.d/pgdg.list \
&& 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 \
fonts-noto-cjk \
fonts-noto-hinted \
fonts-noto-unhinted \
2019-03-15 15:50:46 +00:00
clang \
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 \
postgis \
2019-03-15 15:50:46 +00:00
postgresql-10 \
2019-03-16 21:14:41 +00:00
postgresql-10-postgis-2.5 \
postgresql-10-postgis-2.5-scripts \
2019-03-15 15:50:46 +00:00
postgresql-contrib-10 \
2019-03-14 14:45:25 +00:00
protobuf-c-compiler \
python-mapnik \
sudo \
tar \
ttf-unifont \
unzip \
wget \
2019-03-15 15:50:46 +00:00
zlib1g-dev \
osmosis \
osmium-tool \
cron \
python3-psycopg2 python3-shapely python3-lxml \
2019-03-15 15:50:46 +00:00
&& 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-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
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
2019-03-15 15:50:46 +00:00
RUN cmake .. \
&& make -j $(nproc)
2018-05-08 20:43:34 +00:00
USER root
RUN make install
USER renderer
# Install and test Mapnik
RUN python -c 'import mapnik'
# 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
2019-03-15 15:50:46 +00:00
RUN ./autogen.sh \
&& ./configure \
&& make -j $(nproc)
2018-05-08 20:43:34 +00:00
USER root
2019-03-15 15:50:46 +00:00
RUN make -j $(nproc) install \
&& make -j $(nproc) install-mod_tile \
&& ldconfig
2018-05-08 20:43:34 +00:00
USER renderer
# Configure stylesheet
WORKDIR /home/renderer/src
RUN git clone https://github.com/gravitystorm/openstreetmap-carto.git
WORKDIR /home/renderer/src/openstreetmap-carto
USER root
2019-03-17 19:33:06 +00:00
RUN npm install -g carto
2018-05-08 20:43:34 +00:00
USER renderer
RUN carto project.mml > mapnik.xml
# Load shapefiles
WORKDIR /home/renderer/src/openstreetmap-carto
RUN scripts/get-shapefiles.py
# Configure renderd
USER root
2019-03-15 15:50:46 +00:00
RUN sed -i 's/renderaccount/renderer/g' /usr/local/etc/renderd.conf \
&& sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf
2018-05-08 20:43:34 +00:00
USER renderer
# Configure Apache
USER root
2019-03-15 15:50:46 +00:00
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 \
&& a2enconf mod_tile
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-03-15 17:13:02 +00:00
RUN ln -sf /proc/1/fd/1 /var/log/apache2/access.log \
&& ln -sf /proc/1/fd/2 /var/log/apache2/error.log
2019-01-11 19:37:31 +00:00
# Configure PosgtreSQL
COPY postgresql.custom.conf.tmpl /etc/postgresql/10/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
# 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
# install trim_osc.py helper script
USER renderer
RUN cd ~/src \
&& git clone https://github.com/zverik/regional \
&& chmod u+x ~/src/regional/trim_osc.py
2018-05-08 20:43:34 +00:00
# Start running
USER root
2018-05-08 20:43:34 +00:00
COPY run.sh /
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