forked from Overv/openstreetmap-tile-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
195 lines (179 loc) · 5.45 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
FROM ubuntu:18.04
# Based on
# https://switch2osm.org/manually-building-a-tile-server-18-04-lts/
# Set up environment and renderer user
ENV TZ=Europe/Helsinki
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN adduser --disabled-password --gecos "" renderer
# Install dependencies
RUN apt-get update \
&& apt-get install -y wget gnupg2 lsb-core \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb [ trusted=yes ] https://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list \
&& echo "deb [ trusted=yes ] https://apt-archive.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 curl \
&& wget --quiet -O - https://deb.nodesource.com/setup_10.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
apache2 \
apache2-dev \
autoconf \
build-essential \
bzip2 \
cmake \
cron \
fonts-noto-cjk \
fonts-noto-hinted \
fonts-noto-unhinted \
gcc \
gdal-bin \
git-core \
libagg-dev \
libboost-filesystem-dev \
libboost-system-dev \
libbz2-dev \
libcairo-dev \
libcairomm-1.0-dev \
libexpat1-dev \
libfreetype6-dev \
libgdal-dev \
libgeos++-dev \
libgeos-dev \
libgeotiff-epsg \
libicu-dev \
liblua5.3-dev \
libmapnik-dev \
libpq-dev \
libproj-dev \
libprotobuf-c0-dev \
libtiff5-dev \
libtool \
libxml2-dev \
lua5.3 \
make \
mapnik-utils \
node-gyp \
osmium-tool \
osmosis \
postgis \
postgresql-10 \
postgresql-contrib-10 \
postgresql-server-dev-10 \
protobuf-c-compiler \
python-mapnik \
# python3-lxml \
# python3-psycopg2 \
# python3-shapely \
sudo \
tar \
ttf-unifont \
unzip \
zlib1g-dev \
&& apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
# Set up PostGIS
RUN wget https://download.osgeo.org/postgis/source/postgis-2.4.4.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
# Kubernetes hack, because emptydir-volume does not copy existing data from image
USER root
RUN mv /var/lib/postgresql/10/main /var/lib/postgresql/10/main2 \
&& mkdir /var/lib/postgresql/10/main
# Configure Postgres
COPY --chown=postgres:postgres postgresql.custom.conf /etc/postgresql/10/main/conf.d/
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/10/main/pg_hba.conf
# RUN echo "listen_addresses = '*'" >> /etc/postgresql/10/main/postgresql.conf
# Install latest osm2pgsql
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
USER renderer
# Test Mapnik
RUN python -c 'import mapnik'
# Install mod_tile and renderd
USER root
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 ..
USER renderer
# Configure Apache
USER root
RUN mkdir /var/lib/mod_tile \
&& chown renderer /var/lib/mod_tile
RUN 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
COPY apache.conf /etc/apache2/sites-available/000-default.conf
USER renderer
# Install Carto
USER root
RUN npm install -g carto
USER renderer
# Configure stylesheets
ARG NOCACHE=0
USER root
RUN chown -R renderer:renderer /home/renderer/src
USER renderer
WORKDIR /home/renderer/src
RUN git clone -b pkk_summer https://github.com/MaRaSu/openstreetmap-carto.git pkk_summer
RUN git clone https://github.com/MaRaSu/pkk_winter_2014.git pkk_winter
WORKDIR /home/renderer/src/pkk_summer
RUN wget -nv https://raw.githubusercontent.com/MaRaSu/osm2pgsql_style/master/pkk_maps.style
RUN carto -v
RUN carto project.mml > mapnik.xml
WORKDIR /home/renderer/src/pkk_winter
RUN wget -nv https://raw.githubusercontent.com/Myrtillus/osm2pgsql_style/master/pkk_maps.style
RUN carto -v
RUN carto project.mml > mapnik.xml
# Load shapefiles
WORKDIR /home/renderer/src/pkk_summer
RUN ./get-shapefiles.sh \
&& rm data/*.zip \
&& rm data/*.tgz
WORKDIR /home/renderer/src/pkk_winter
RUN ln -s ../pkk_summer/data .
# Copy config files
USER root
COPY run.sh /
COPY pre_render.py /usr/local/bin/
COPY renderd.conf /usr/local/etc/
RUN chmod a+x /usr/local/bin/pre_render.py
COPY index.html /var/www/html/
# Add healthcheck script to Apache at /health
COPY healthcheck.py /var/www/html/health/
RUN chmod a+x /var/www/html/health/healthcheck.py
COPY apache_enable_cgi.txt /etc/apache2/
RUN cat /etc/apache2/apache_enable_cgi.txt >> /etc/apache2/apache2.conf
WORKDIR /etc/apache2/mods-enabled
RUN ln -s ../mods-available/cgid.conf .
RUN ln -s ../mods-available/cgid.load .
# Entrypoint
ENTRYPOINT ["/run.sh"]
CMD []
EXPOSE 80
EXPOSE 5432