2022-07-05 12:23:15 +00:00
|
|
|
FROM ubuntu:22.04 AS compiler-common
|
2021-10-11 20:15:44 +00:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
2023-03-18 20:45:25 +00:00
|
|
|
ENV LANG C.UTF-8
|
|
|
|
ENV LC_ALL C.UTF-8
|
2021-10-11 20:15:44 +00:00
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y --no-install-recommends \
|
2023-03-18 20:45:25 +00:00
|
|
|
ca-certificates gnupg lsb-release locales \
|
|
|
|
wget curl \
|
|
|
|
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
|
2021-10-11 20:15:44 +00:00
|
|
|
|
|
|
|
###########################################################################################################
|
|
|
|
|
|
|
|
FROM compiler-common AS compiler-stylesheet
|
|
|
|
RUN cd ~ \
|
2022-03-28 13:12:13 +00:00
|
|
|
&& git clone --single-branch --branch v5.4.0 https://github.com/gravitystorm/openstreetmap-carto.git --depth 1 \
|
2021-10-11 20:15:44 +00:00
|
|
|
&& cd openstreetmap-carto \
|
2022-08-03 21:40:03 +00:00
|
|
|
&& 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 \
|
2022-03-31 11:44:56 +00:00
|
|
|
&& rm -rf .git
|
2021-10-11 20:15:44 +00:00
|
|
|
|
|
|
|
###########################################################################################################
|
|
|
|
|
|
|
|
FROM compiler-common AS compiler-helper-script
|
|
|
|
RUN mkdir -p /home/renderer/src \
|
|
|
|
&& cd /home/renderer/src \
|
|
|
|
&& git clone https://github.com/zverik/regional \
|
|
|
|
&& cd regional \
|
|
|
|
&& rm -rf .git \
|
|
|
|
&& chmod u+x /home/renderer/src/regional/trim_osc.py
|
|
|
|
|
|
|
|
###########################################################################################################
|
|
|
|
|
2023-03-18 20:45:25 +00:00
|
|
|
FROM compiler-common AS final
|
2018-05-08 20:43:34 +00:00
|
|
|
|
|
|
|
# Based on
|
2021-02-07 20:56:36 +00:00
|
|
|
# https://switch2osm.org/serving-tiles/manually-building-a-tile-server-18-04-lts/
|
2021-10-11 20:15:44 +00:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
2019-04-16 05:45:10 +00:00
|
|
|
ENV AUTOVACUUM=on
|
2019-06-13 13:39:04 +00:00
|
|
|
ENV UPDATES=disabled
|
2022-07-22 13:18:24 +00:00
|
|
|
ENV REPLICATION_URL=https://planet.openstreetmap.org/replication/hour/
|
|
|
|
ENV MAX_INTERVAL_SECONDS=3600
|
2023-03-18 20:45:25 +00:00
|
|
|
ENV PG_VERSION 15
|
2022-07-22 13:18:24 +00:00
|
|
|
|
2019-03-14 14:56:07 +00:00
|
|
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
|
|
|
2021-10-11 20:15:44 +00:00
|
|
|
# Get packages
|
2019-10-22 21:11:50 +00:00
|
|
|
RUN apt-get update \
|
2021-10-11 20:15:44 +00:00
|
|
|
&& apt-get install -y --no-install-recommends \
|
|
|
|
apache2 \
|
|
|
|
cron \
|
2022-07-05 12:23:15 +00:00
|
|
|
dateutils \
|
2022-08-03 21:40:03 +00:00
|
|
|
fonts-hanazono \
|
2021-10-11 20:15:44 +00:00
|
|
|
fonts-noto-cjk \
|
|
|
|
fonts-noto-hinted \
|
|
|
|
fonts-noto-unhinted \
|
2022-07-05 12:23:15 +00:00
|
|
|
fonts-unifont \
|
2022-03-28 13:12:13 +00:00
|
|
|
gnupg2 \
|
2021-10-11 20:15:44 +00:00
|
|
|
gdal-bin \
|
|
|
|
liblua5.3-dev \
|
|
|
|
lua5.3 \
|
|
|
|
mapnik-utils \
|
2022-03-31 11:44:56 +00:00
|
|
|
npm \
|
2022-07-05 12:23:15 +00:00
|
|
|
osm2pgsql \
|
2021-10-11 20:15:44 +00:00
|
|
|
osmium-tool \
|
|
|
|
osmosis \
|
2023-03-18 20:45:25 +00:00
|
|
|
postgresql-$PG_VERSION \
|
|
|
|
postgresql-$PG_VERSION-postgis-3 \
|
|
|
|
postgresql-$PG_VERSION-postgis-3-scripts \
|
2022-07-05 12:23:15 +00:00
|
|
|
postgis \
|
2021-10-11 20:15:44 +00:00
|
|
|
python-is-python3 \
|
|
|
|
python3-mapnik \
|
|
|
|
python3-lxml \
|
|
|
|
python3-psycopg2 \
|
|
|
|
python3-shapely \
|
|
|
|
python3-pip \
|
2022-07-05 12:23:15 +00:00
|
|
|
renderd \
|
2021-10-11 20:15:44 +00:00
|
|
|
sudo \
|
2023-03-18 20:45:25 +00:00
|
|
|
vim \
|
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
|
|
|
|
|
|
|
RUN adduser --disabled-password --gecos "" renderer
|
|
|
|
|
2022-08-03 21:40:03 +00:00
|
|
|
# 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/
|
|
|
|
|
2021-10-11 20:15:44 +00:00
|
|
|
# Install python libraries
|
|
|
|
RUN pip3 install \
|
|
|
|
requests \
|
2022-03-31 11:44:56 +00:00
|
|
|
osmium \
|
2021-10-11 20:15:44 +00:00
|
|
|
pyyaml
|
2022-07-05 12:23:15 +00:00
|
|
|
|
2022-03-31 11:44:56 +00:00
|
|
|
# Install carto for stylesheet
|
|
|
|
RUN npm install -g carto@0.18.2
|
2018-05-08 20:43:34 +00:00
|
|
|
|
|
|
|
# Configure Apache
|
2022-07-05 12:23:15 +00:00
|
|
|
RUN echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \
|
2021-10-11 20:15:44 +00:00
|
|
|
&& 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-09-17 20:03:03 +00:00
|
|
|
RUN ln -sf /dev/stdout /var/log/apache2/access.log \
|
2021-10-11 20:15:44 +00:00
|
|
|
&& ln -sf /dev/stderr /var/log/apache2/error.log
|
|
|
|
|
2022-09-27 14:03:13 +00:00
|
|
|
# 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
|
|
|
|
|
2022-09-27 14:00:44 +00:00
|
|
|
# Icon
|
|
|
|
RUN wget -O /var/www/html/favicon.ico https://www.openstreetmap.org/favicon.ico
|
|
|
|
|
2021-10-11 20:15:44 +00:00
|
|
|
# Copy update scripts
|
2022-04-09 13:00:29 +00:00
|
|
|
COPY openstreetmap-tiles-update-expire.sh /usr/bin/
|
|
|
|
RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire.sh \
|
2021-10-11 20:15:44 +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 \
|
2022-04-09 13:00:29 +00:00
|
|
|
&& echo "* * * * * renderer openstreetmap-tiles-update-expire.sh\n" >> /etc/crontab
|
2019-01-11 19:37:31 +00:00
|
|
|
|
2019-03-15 17:33:40 +00:00
|
|
|
# Configure PosgtreSQL
|
2023-03-18 20:45:25 +00:00
|
|
|
COPY postgresql.custom.conf.tmpl /etc/postgresql/$PG_VERSION/main/
|
2019-03-15 18:20:59 +00:00
|
|
|
RUN chown -R postgres:postgres /var/lib/postgresql \
|
2023-03-18 20:45:25 +00:00
|
|
|
&& chown postgres:postgres /etc/postgresql/$PG_VERSION/main/postgresql.custom.conf.tmpl \
|
|
|
|
&& 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 scram-sha-256" >> /etc/postgresql/$PG_VERSION/main/pg_hba.conf
|
2021-10-11 20:15:44 +00:00
|
|
|
|
2022-04-09 13:00:29 +00:00
|
|
|
# Create volume directories
|
2022-07-05 12:23:15 +00:00
|
|
|
RUN mkdir -p /run/renderd/ \
|
|
|
|
&& mkdir -p /data/database/ \
|
2022-04-09 13:00:29 +00:00
|
|
|
&& mkdir -p /data/style/ \
|
|
|
|
&& mkdir -p /home/renderer/src/ \
|
|
|
|
&& chown -R renderer: /data/ \
|
|
|
|
&& chown -R renderer: /home/renderer/src/ \
|
2022-07-05 12:23:15 +00:00
|
|
|
&& chown -R renderer: /run/renderd \
|
2023-03-18 20:45:25 +00:00
|
|
|
&& mv /var/lib/postgresql/$PG_VERSION/main/ /data/database/postgres/ \
|
2022-07-05 12:23:15 +00:00
|
|
|
&& mv /var/cache/renderd/tiles/ /data/tiles/ \
|
|
|
|
&& chown -R renderer: /data/tiles \
|
2023-03-18 20:45:25 +00:00
|
|
|
&& ln -s /data/database/postgres /var/lib/postgresql/$PG_VERSION/main \
|
2022-04-09 13:00:29 +00:00
|
|
|
&& ln -s /data/style /home/renderer/src/openstreetmap-carto \
|
2022-07-05 12:23:15 +00:00
|
|
|
&& ln -s /data/tiles /var/cache/renderd/tiles \
|
2022-04-09 13:00:29 +00:00
|
|
|
;
|
2021-10-11 20:15:44 +00:00
|
|
|
|
2022-07-05 12:23:15 +00:00
|
|
|
RUN echo '[default] \n\
|
|
|
|
URI=/tile/ \n\
|
|
|
|
TILEDIR=/var/cache/renderd/tiles \n\
|
|
|
|
XML=/home/renderer/src/openstreetmap-carto/mapnik.xml \n\
|
|
|
|
HOST=localhost \n\
|
|
|
|
TILESIZE=256 \n\
|
2022-08-03 21:40:03 +00:00
|
|
|
MAXZOOM=20' >> /etc/renderd.conf \
|
|
|
|
&& sed -i 's,/usr/share/fonts/truetype,/usr/share/fonts,g' /etc/renderd.conf
|
2019-06-13 13:39:04 +00:00
|
|
|
|
2021-10-11 20:15:44 +00:00
|
|
|
# Install helper script
|
|
|
|
COPY --from=compiler-helper-script /home/renderer/src/regional /home/renderer/src/regional
|
2019-06-13 13:39:04 +00:00
|
|
|
|
2022-03-31 11:44:56 +00:00
|
|
|
COPY --from=compiler-stylesheet /root/openstreetmap-carto /home/renderer/src/openstreetmap-carto-backup
|
|
|
|
|
2018-05-08 20:43:34 +00:00
|
|
|
# Start running
|
|
|
|
COPY run.sh /
|
2023-07-03 13:53:12 +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
|