-
Notifications
You must be signed in to change notification settings - Fork 444
/
Dockerfile
156 lines (134 loc) · 3.83 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
ARG NOMINATIM_VERSION=4.3.2
ARG USER_AGENT=mediagis/nominatim-docker:${NOMINATIM_VERSION}
FROM ubuntu:jammy AS build
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
WORKDIR /app
RUN true \
# Do not start daemons after installation.
&& echo '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d \
&& chmod +x /usr/sbin/policy-rc.d \
# Install all required packages.
&& apt-get -y update -qq \
&& apt-get -y install \
locales \
&& locale-gen en_US.UTF-8 \
&& update-locale LANG=en_US.UTF-8 \
&& apt-get -y install \
-o APT::Install-Recommends="false" \
-o APT::Install-Suggests="false" \
# Build tools from sources.
build-essential \
g++ \
cmake \
libpq-dev \
zlib1g-dev \
libbz2-dev \
libproj-dev \
libexpat1-dev \
libboost-dev \
libboost-system-dev \
libboost-filesystem-dev \
liblua5.4-dev \
nlohmann-json3-dev \
# PostgreSQL.
postgresql-contrib \
postgresql-server-dev-14 \
postgresql-14-postgis-3 \
postgresql-14-postgis-3-scripts \
# PHP and Apache 2.
php \
php-intl \
php-pgsql \
php-cgi \
apache2 \
libapache2-mod-php \
# Python 3.
python3-dev \
python3-pip \
python3-tidylib \
python3-psycopg2 \
python3-setuptools \
python3-dotenv \
python3-psutil \
python3-jinja2 \
python3-sqlalchemy \
python3-asyncpg \
python3-datrie \
python3-icu \
python3-argparse-manpage \
# Misc.
git \
curl \
sudo \
sshpass \
openssh-client
# Configure postgres.
RUN true \
&& echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/14/main/pg_hba.conf \
&& echo "listen_addresses='*'" >> /etc/postgresql/14/main/postgresql.conf
# Osmium install to run continuous updates.
RUN pip3 install osmium
# Nominatim install.
ARG NOMINATIM_VERSION
ARG USER_AGENT
RUN true \
&& curl -A $USER_AGENT https://nominatim.org/release/Nominatim-$NOMINATIM_VERSION.tar.bz2 -o nominatim.tar.bz2 \
&& tar xf nominatim.tar.bz2 \
&& mkdir build \
&& cd build \
&& cmake ../Nominatim-$NOMINATIM_VERSION \
&& make -j`nproc` \
&& make install
RUN true \
# Remove development and unused packages.
&& apt-get -y remove --purge \
cpp-9 \
gcc-9* \
g++ \
git \
make \
cmake* \
llvm-10* \
libc6-dev \
linux-libc-dev \
libclang-*-dev \
build-essential \
liblua*-dev \
postgresql-server-dev-14 \
nlohmann-json3-dev \
&& apt-get clean \
# Clear temporary files and directories.
&& rm -rf \
/tmp/* \
/var/tmp/* \
/root/.cache \
/app/src/.git \
/var/lib/apt/lists/* \
# Remove nominatim source and build directories
&& rm /app/*.tar.bz2 \
&& rm -rf /app/build \
&& rm -rf /app/Nominatim-$NOMINATIM_VERSION
# Apache configuration
COPY conf.d/apache.conf /etc/apache2/sites-enabled/000-default.conf
# Postgres config overrides to improve import performance (but reduce crash recovery safety)
COPY conf.d/postgres-import.conf /etc/postgresql/14/main/conf.d/postgres-import.conf.disabled
COPY conf.d/postgres-tuning.conf /etc/postgresql/14/main/conf.d/
COPY config.sh /app/config.sh
COPY init.sh /app/init.sh
COPY start.sh /app/start.sh
COPY startapache.sh /app/startapache.sh
COPY startpostgres.sh /app/startpostgres.sh
# Collapse image to single layer.
FROM scratch
COPY --from=build / /
# Please override this
ENV NOMINATIM_PASSWORD=qaIACxO6wMR3
ENV PROJECT_DIR=/nominatim
ARG USER_AGENT
ENV USER_AGENT=${USER_AGENT}
WORKDIR /app
EXPOSE 5432
EXPOSE 8080
COPY conf.d/env $PROJECT_DIR/.env
CMD ["/app/start.sh"]