Skip to content

Commit

Permalink
Merge pull request #587 from mediagis/nominatim-4.5
Browse files Browse the repository at this point in the history
Nominatim 4.5
  • Loading branch information
leonardehrenfried authored Nov 13, 2024
2 parents 2212081 + d8abeb7 commit b1ca923
Show file tree
Hide file tree
Showing 13 changed files with 823 additions and 10 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
strategy:
matrix:
nominatim:
- version: "4.3"
- version: "4.4"

- version: "4.5"

runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -43,9 +43,9 @@ jobs:
strategy:
matrix:
nominatim:
- version: "4.3"
- version: "4.4"

- version: "4.5"

test_scenario:
- name: Import with PBF_URL and update
commands: |-
Expand Down Expand Up @@ -89,6 +89,8 @@ jobs:
# Stop container
docker stop nominatim
# the container needs a few seconds to shutdown cleanly apparently
sleep 15
# import to bind mount is done previously
docker run -i --rm \
Expand Down Expand Up @@ -196,7 +198,7 @@ jobs:
- name: GB postcode import
commands: |-
docker run -i --rm \
-e PBF_URL=https://download.geofabrik.de/europe/great-britain/england/rutland-latest.osm.pbf \
-e PBF_URL=https://download.geofabrik.de/europe/united-kingdom/england/rutland-latest.osm.pbf \
-e IMPORT_GB_POSTCODES="true" \
-p 8010:8080 \
nominatim &
Expand All @@ -213,7 +215,7 @@ jobs:
-p 8011:8080 \
nominatim &
./assert-reverse-only "http://localhost:8011/search.php?q=avenue%20pasteur"
#./assert-reverse-only "http://localhost:8011/search.php?q=avenue%20pasteur"
./assert-non-empty-json "http://localhost:8011/reverse.php?lat=43.734&lon=7.42&format=jsonv2"
- name: Check for clean shutdown
Expand Down Expand Up @@ -257,9 +259,9 @@ jobs:
strategy:
matrix:
nominatim:
- version: "4.3"
- version: "4.4"

- version: "4.5"

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
108 changes: 108 additions & 0 deletions 4.5/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
ARG NOMINATIM_VERSION=4.5.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 \
# PostgreSQL.
postgresql-contrib \
postgresql-server-dev-16 \
postgresql-16-postgis-3 \
postgresql-16-postgis-3-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 \
postgresql-server-dev-16 \
# 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 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"]
Loading

0 comments on commit b1ca923

Please sign in to comment.