forked from peter-evans/nominatim-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
144 lines (121 loc) · 4.33 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
ARG nominatim_version=3.5.2
FROM ubuntu:focal as builder
ARG nominatim_version
# Let the container know that there is no TTY
ARG DEBIAN_FRONTEND=noninteractive
# Install packages
RUN apt-get -y update \
&& apt-get install -y -qq --no-install-recommends \
build-essential \
cmake \
g++ \
libboost-dev \
libboost-system-dev \
libboost-filesystem-dev \
libexpat1-dev \
zlib1g-dev \
libxml2-dev \
libbz2-dev \
libpq-dev \
libgeos-dev \
libgeos++-dev \
libproj-dev \
php \
curl \
ca-certificates \
gnupg \
lsb-release
# Install postgres
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
&& apt-get update \
&& apt-get install -y -qq postgresql-13 postgresql-13-postgis-3 postgresql-server-dev-13
# Build Nominatim
RUN cd /srv \
&& curl --silent -L http://www.nominatim.org/release/Nominatim-${nominatim_version}.tar.bz2 -o v${nominatim_version}.tar.bz2 \
&& tar xf v${nominatim_version}.tar.bz2 \
&& rm v${nominatim_version}.tar.bz2 \
&& mv Nominatim-${nominatim_version} nominatim \
&& cd nominatim \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make
FROM ubuntu:focal
ARG nominatim_version
LABEL \
maintainer="Peter Evans <[email protected]>" \
org.opencontainers.image.title="nominatim-k8s" \
org.opencontainers.image.description="Nominatim for Kubernetes on Google Container Engine (GKE)." \
org.opencontainers.image.authors="Peter Evans <[email protected]>" \
org.opencontainers.image.url="https://github.com/peter-evans/nominatim-k8s" \
org.opencontainers.image.vendor="https://peterevans.dev" \
org.opencontainers.image.licenses="MIT" \
app.tag="nominatim${nominatim_version}"
# Let the container know that there is no TTY
ARG DEBIAN_FRONTEND=noninteractive
# Set locale and install packages
ENV LANG C.UTF-8
RUN apt-get -y update \
&& apt-get install -y -qq --no-install-recommends locales \
&& locale-gen en_US.UTF-8 \
&& update-locale LANG=en_US.UTF-8 \
&& apt-get install -y -qq --no-install-recommends \
apache2 \
php \
php-pgsql \
libapache2-mod-php \
php-pear \
php-db \
php-intl \
python3-dev \
python3-psycopg2 \
curl \
ca-certificates \
sudo \
gnupg \
lsb-release \
less \
libboost-dev \
libboost-system-dev \
libboost-filesystem-dev \
supervisor \
osmium-tool \
wget \
python3-pip \
tree
# Install postgres
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
&& apt-get update \
&& apt-get install -y -qq postgresql-13 postgresql-13-postgis-3 postgresql-server-dev-13
RUN pip3 install osmium
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/* /var/tmp/* \
&& mkdir -p /var/log/supervisor
# Setup user
RUN useradd -ms /bin/bash nominatim
# Setup supervisord
COPY assets/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Copy the application from the builder image
COPY --from=builder /srv/nominatim /srv/nominatim
# Configure Nominatim
COPY assets/local.php /srv/nominatim/build/settings/local.php
COPY assets/import_multiple_regions.sh /srv/nominatim/build/utils/import_multiple_regions.sh
COPY assets/update_multiple_regions.sh /srv/nominatim/build/utils/update_multiple_regions.sh
# Configure Apache
COPY assets/nominatim.conf /etc/apache2/sites-enabled/000-default.conf
# Allow remote connections to PostgreSQL
RUN echo "host all all 127.0.0.1/32 trust" >> /etc/postgresql/13/main/pg_hba.conf \
&& echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/13/main/pg_hba.conf \
&& echo "listen_addresses = '*'" >> /etc/postgresql/13/main/postgresql.conf \
&& echo "log_destination = 'stderr'" >> /etc/postgresql/13/main/postgresql.conf \
&& echo "log_checkpoints = on" >> /etc/postgresql/13/main/postgresql.conf \
&& echo "include_dir = '/postgresql_conf.d/'" >> /etc/postgresql/13/main/postgresql.conf
# Set the entrypoint
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 5432
EXPOSE 8080