-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
109 lines (88 loc) · 4.84 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
FROM ubuntu:18.04
RUN apt-get -y update && apt-get -y install libboost-all-dev git-core tar unzip wget bzip2 build-essential autoconf\
libtool libxml2-dev libgeos-dev libgeos++-dev libpq-dev libbz2-dev libproj-dev munin-node munin\
libprotobuf-c0-dev protobuf-c-compiler libfreetype6-dev libtiff5-dev libicu-dev libgdal-dev\
libcairo-dev libcairomm-1.0-dev apache2 apache2-dev libagg-dev liblua5.2-dev ttf-unifont lua5.1\
liblua5.1-dev libgeotiff-epsg curl
#install and configure Postgres
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -y install postgresql postgresql-contrib postgis postgresql-10-postgis-2.4 postgresql-10-postgis-scripts
USER postgres
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\
createdb -E UTF8 -O docker gis &&\
psql --dbname=gis --command "CREATE EXTENSION hstore;" &&\
psql --dbname=gis --command "CREATE EXTENSION postgis;" &&\
psql --dbname=gis --command "ALTER TABLE geometry_columns OWNER TO docker;" &&\
psql --dbname=gis --command "ALTER TABLE spatial_ref_sys OWNER TO docker;" &&\
/etc/init.d/postgresql stop
#build osm2pgsql
USER root
RUN git clone https://github.com/openstreetmap/osm2pgsql.git ~postgres/src/osm2pgsql --depth 1 --branch 1.8.1
RUN apt-get -y install make cmake g++ libboost-dev libboost-system-dev libboost-filesystem-dev libexpat1-dev\
zlib1g-dev libbz2-dev libpq-dev libgeos-dev libgeos++-dev libproj-dev lua5.2 liblua5.2-dev osmctools
RUN cd ~postgres/src/osm2pgsql && mkdir build && cd build && cmake .. && make && make install
#install Mapnik
RUN apt-get -y install autoconf apache2-dev libtool libxml2-dev libbz2-dev libgeos-dev libgeos++-dev\
libproj-dev gdal-bin libmapnik-dev mapnik-utils python-mapnik sudo
#build mod_tile and renderd
# Newer commits in mod_tile remove the renderd.init file since the project is now in Debian / Ubuntu
# official repositories, which provide their own init configuration, but those packages are only in
# newer versions. Once we update this container to use 22.04, or another newer Ubuntu version, we can
# install mod_tile that way and avoid having to build it ourselves entirely.
RUN git clone https://github.com/openstreetmap/mod_tile.git ~postgres/src/mod_tile
RUN cd ~postgres/src/mod_tile && git reset fd5988fc5877c51838ad96991d6e2912cfaf7d61 --hard && ./autogen.sh && ./configure && make && make install && make install-mod_tile && ldconfig
#build carto (map style configuration)
RUN apt-get install -y npm nodejs node-gyp nodejs-dev libssl1.0-dev
RUN npm install -g carto
# install kosmtik
RUN npm -g install kosmtik
#install fonts
RUN apt-get -y install fonts-noto-cjk fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted fonts-hanazono ttf-unifont\
ttf-dejavu ttf-dejavu-core ttf-dejavu-extra cabextract
#configure renderd
USER root
COPY etc/renderd.conf /usr/local/etc/renderd.conf
RUN mkdir /var/lib/mod_tile && chown postgres:postgres /var/lib/mod_tile
RUN mkdir /var/run/renderd && chown postgres:postgres /var/run/renderd
COPY etc/default_renderd.sh /etc/default/renderd
RUN cp ~postgres/src/mod_tile/debian/renderd.init /etc/init.d/renderd && chmod a+x /etc/init.d/renderd
RUN rm /etc/apache2/sites-enabled/000-default.conf
# configure apache
RUN echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" > /etc/apache2/mods-available/tile.load
RUN a2enmod tile
RUN a2enmod proxy
RUN a2enmod proxy_http
COPY etc/apache2_renderd.conf /etc/apache2/sites-available/renderd.conf
COPY etc/apache2_kosmtik.conf /etc/apache2/sites-available/kosmtik.conf
# additional fonts requred for pre-rendering
RUN cd /usr/share/fonts/truetype/noto/ && \
wget https://github.com/googlefonts/noto-emoji/raw/main/fonts/NotoColorEmoji.ttf
# generate tile scripts
RUN apt-get -y install python-pip
RUN pip install awscli
RUN aws configure set default.s3.max_concurrent_requests 100
COPY etc/generate_tiles.py /var/lib/postgresql/src/generate_tiles.py
# install and configure styles
COPY etc/configure.py /style/configure.py
COPY etc/osm-smartrak/make.py /style/make.py
COPY etc/osm-smartrak/utils.py /style/utils.py
# add base styles to each theme directory first. The files specified in each theme directory may override these.
COPY etc/osm-smartrak/style /style/themes/default/
COPY etc/osm-smartrak/style /style/themes/skate/
COPY etc/default-style /style/themes/default/
COPY etc/skate-style /style/themes/skate/
# fix permissions
RUN chown -R postgres:postgres ~postgres/
RUN chown -R postgres:postgres /style
# copy test pages
COPY ./local.html /var/www/html/
COPY ./prod.html /var/www/html/
COPY ./dev.html /var/www/html/
# simulate a health check
RUN touch /var/www/html/_health
# copy map data loader script
COPY ./load_map_data.sh /
COPY ./docker-entrypoint.sh /
EXPOSE 80
ENTRYPOINT ["/docker-entrypoint.sh"]