-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
178 lines (149 loc) · 5.26 KB
/
Dockerfile
File metadata and controls
178 lines (149 loc) · 5.26 KB
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
FROM ubuntu:22.04 AS compiler-common
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git-core \
ca-certificates
###########################################################################################################
FROM compiler-common AS compiler-stylesheet
RUN cd $HOME \
&& git clone --depth 1 https://github.com/gravitystorm/openstreetmap-carto.git \
&& cd openstreetmap-carto \
&& 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 \
&& rm -rf .git
###########################################################################################################
FROM compiler-common AS compiler-helper-script
RUN cd $HOME \
&& git clone --depth 1 https://github.com/zverik/regional \
&& cd regional \
&& chmod u+x trim_osc.py \
&& rm -rf .git
###########################################################################################################
FROM compiler-common AS compiler-osm2pgsql
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
make \
cmake \
g++ \
libboost-dev \
libboost-system-dev \
libboost-filesystem-dev \
libexpat1-dev \
zlib1g-dev \
libbz2-dev \
libpq-dev \
libproj-dev \
lua5.3 \
liblua5.3-dev \
pandoc
RUN cd $HOME \
&& git clone --depth 1 https://github.com/openstreetmap/osm2pgsql \
&& cd osm2pgsql \
&& mkdir -p build \
&& cd build \
&& cmake .. \
&& make \
&& make install \
&& rm -rf .git
###########################################################################################################
FROM ubuntu:22.04 AS final
# Based on https://switch2osm.org/serving-tiles/manually-building-a-tile-server-18-04-lts/
ENV DEBIAN_FRONTEND=noninteractive
ENV USER=_tirex
ENV POSTGRESQL_VER=15
ENV PGDATA=/var/lib/postgresql/$POSTGRESQL_VER/main
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ARG TZ=America/Montreal
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates gnupg lsb-release locales \
sudo 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
# Add postgresql-$POSTGRESQL_VER repository
# RUN echo "deb http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
# && wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | tee /etc/apt/trusted.gpg.d/pgdg.asc
# Get packages
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apache2 \
cron \
dateutils \
fonts-hanazono \
fonts-noto-cjk \
fonts-noto-hinted \
fonts-noto-unhinted \
fonts-unifont \
gdal-bin \
liblua5.3-dev \
lua5.3 \
mapnik-utils \
nano \
npm \
osmium-tool \
osmosis \
postgresql-$POSTGRESQL_VER \
postgresql-client-$POSTGRESQL_VER \
postgresql-$POSTGRESQL_VER-postgis-3 \
postgresql-$POSTGRESQL_VER-postgis-3-scripts \
postgis \
python-is-python3 \
python3-mapnik \
python3-lxml \
python3-psycopg2 \
python3-shapely \
python3-pip \
tirex \
tirex-example-map \
systemctl \
vim \
&& apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
# 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/
# Install python libraries
RUN pip3 install \
requests \
osmium \
pyyaml
# Install carto for stylesheet
RUN npm install -g carto
# Icon
RUN wget -O /var/www/html/favicon.ico https://www.openstreetmap.org/favicon.ico
# Create volume directories
RUN mkdir -p /run/tirex/ \
&& mkdir -p /home/$USER/src/ \
&& mkdir -p /data/database/ \
&& mkdir -p /data/style/ \
&& mkdir -p /data/config \
&& chown -R $USER: /run/tirex/ \
;
# Copy config files
COPY config/postgresql.custom.conf /data/config
COPY config/tirex.conf /data/config
COPY config/mapnik.conf /data/config
COPY config/region.conf /data/config
COPY config/tirex-region.conf /data/config
COPY config/index.html /data/config
# Install helper scripts
COPY --from=compiler-helper-script /root/regional /home/$USER/src/regional
COPY --from=compiler-stylesheet /root/openstreetmap-carto /home/$USER/src/openstreetmap-carto-backup
COPY --from=compiler-osm2pgsql /root/osm2pgsql/build/osm2pgsql /usr/local/bin/osm2pgsql
COPY --from=compiler-osm2pgsql /root/osm2pgsql/scripts/osm2pgsql-replication /usr/local/bin/osm2pgsql-replication
# Start running
COPY run.sh /
ENTRYPOINT ["/run.sh"]
CMD []
#EXPOSE 80 8080 5432
EXPOSE 80 8080