-
Notifications
You must be signed in to change notification settings - Fork 483
Expand file tree
/
Copy pathDockerfile
More file actions
107 lines (86 loc) · 2.83 KB
/
Dockerfile
File metadata and controls
107 lines (86 loc) · 2.83 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
ARG NOMINATIM_VERSION=5.2.0
ARG USER_AGENT=mediagis/nominatim-docker:${NOMINATIM_VERSION}
FROM ubuntu:24.04 AS build
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
WORKDIR /app
# Inspired by https://github.com/reproducible-containers/buildkit-cache-dance?tab=readme-ov-file#apt-get-github-actions
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
# Keep downloaded APT packages in the docker build cache
rm -f /etc/apt/apt.conf.d/docker-clean && \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache && \
# 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 \
osm2pgsql \
pkg-config \
libicu-dev \
python3-dev \
python3-pip \
python3-icu \
# PostgreSQL.
postgresql-postgis \
postgresql-postgis-scripts \
# Misc.
curl \
sudo \
sshpass \
openssh-client
# Configure postgres.
RUN true \
&& echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/16/main/pg_hba.conf \
&& echo "listen_addresses='*'" >> /etc/postgresql/16/main/postgresql.conf
ARG NOMINATIM_VERSION
ARG USER_AGENT
# Nominatim install.
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked pip install --break-system-packages \
nominatim-db==$NOMINATIM_VERSION \
osmium \
psycopg[binary] \
falcon \
uvicorn \
gunicorn \
nominatim-api
# remove build-only packages
RUN true \
# Remove development and unused packages.
&& apt-get -y remove --purge --auto-remove \
build-essential \
# Clear temporary files and directories.
&& rm -rf \
/tmp/* \
/var/tmp/* \
&& pip cache purge
# Postgres config overrides to improve import performance (but reduce crash recovery safety)
COPY conf.d/postgres-import.conf /etc/postgresql/16/main/conf.d/postgres-import.conf.disabled
COPY conf.d/postgres-tuning.conf /etc/postgresql/16/main/conf.d/
COPY config.sh /app/config.sh
COPY init.sh /app/init.sh
COPY start.sh /app/start.sh
# Collapse image to single layer.
FROM scratch
COPY --from=build / /
# Please override this
ENV NOMINATIM_PASSWORD=qaIACxO6wMR3
ENV WARMUP_ON_STARTUP=false
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"]