-
Notifications
You must be signed in to change notification settings - Fork 450
/
Copy pathDockerfile
144 lines (126 loc) · 3.6 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
FROM ubuntu:focal 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 \
# PostgreSQL.
postgresql-contrib \
postgresql-server-dev-12 \
postgresql-12-postgis-3 \
postgresql-12-postgis-3-scripts \
# PHP and Apache 2.
php \
php-intl \
php-pgsql \
apache2 \
libapache2-mod-php \
# Python 3.
python3-dev \
python3-pip \
python3-tidylib \
python3-psycopg2 \
python3-setuptools \
# Misc.
git \
curl \
sudo
# Configure postgres.
RUN true \
&& echo "host all all 0.0.0.0/0 trust" >> /etc/postgresql/12/main/pg_hba.conf \
&& echo "listen_addresses='*'" >> /etc/postgresql/12/main/postgresql.conf
# Osmium install to run continuous updates.
RUN pip3 install osmium
# Nominatim install.
ENV NOMINATIM_VERSION v3.5.2
RUN true \
&& git clone \
--config advice.detachedHead=false \
--single-branch \
--branch $NOMINATIM_VERSION \
--depth 1 \
--recursive \
https://github.com/openstreetmap/Nominatim \
src \
&& cd src \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make -j`nproc` \
&& chmod o=rwx .
# Apache configure.
COPY local.php /app/src/build/settings/local.php
COPY nominatim.conf /etc/apache2/sites-enabled/000-default.conf
# Load initial data.
ARG with_postcodes_gb
ARG with_postcodes_us
RUN if [ "$with_postcodes_gb" = "" ]; then \
echo "Skipping optional GB postcode file"; \
else \
echo "Downloading optional GB postcode file"; \
curl https://www.nominatim.org/data/gb_postcode_data.sql.gz > /app/src/data/gb_postcode_data.sql.gz; \
fi;
RUN if [ "$with_postcodes_us" = "" ]; then \
echo "Skipping optional US postcode file"; \
else \
echo "Downloading optional US postcode file"; \
curl https://www.nominatim.org/data/us_postcode_data.sql.gz > /app/src/data/us_postcode_data.sql.gz; \
fi;
RUN curl https://nominatim.org/data/country_grid.sql.gz > /app/src/data/country_osm_grid.sql.gz
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 \
postgresql-server-dev-12 \
&& apt-get clean \
# Clear temporary files and directories.
&& rm -rf \
/tmp/* \
/var/tmp/* \
/root/.cache \
/app/src/.git \
/var/lib/apt/lists/* \
/var/lib/postgresql/12/main/*
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 / /
WORKDIR /app
EXPOSE 5432
EXPOSE 8080