Skip to content

Commit 001e790

Browse files
committed
v3.4, new Python API, removed PHP
1 parent 214dee0 commit 001e790

File tree

8 files changed

+53
-47
lines changed

8 files changed

+53
-47
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ n7m is Nominatim packaged in Docker images with separation of responsibilities b
88

99
## Overview
1010
This set of Docker images seperates responsbility into 5 areas:
11-
* **n7m-app** - The main Nomainatim service running PHP-FPM connecting to `n7m-gis`
11+
* **n7m-app** - The main Nomainatim service running uvicorn connecting to `n7m-gis`
1212
* **feed** - Uses the `n7m-app` image to set up the `n7m-gis` database. Can also be used for updates and downloading files.
1313
* **n7m-gis** - Postgis database
1414
* **n7m-ui** - Test web user interface

app/Dockerfile

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1919
liblua5.4-dev \
2020
libpq-dev \
2121
libproj-dev \
22+
nlohmann-json3-dev \
2223
php \
2324
python3 \
2425
zlib1g-dev
2526

26-
ENV NOMINATIM_VERSION=4.2.3
27+
ENV NOMINATIM_VERSION=4.3.2
2728

2829
# Fetch
2930
WORKDIR /nominatim
@@ -48,20 +49,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4849
curl \
4950
liblua5.4 \
5051
libproj-dev \
51-
php \
52-
php-fpm \
53-
php-pgsql \
54-
php-intl \
5552
postgresql-client-14 \
5653
python3-asyncpg \
5754
python3-datrie \
5855
python3-dotenv \
56+
python3-falcon \
5957
python3-geoalchemy2 \
6058
python3-icu \
6159
python3-jinja2 \
6260
python3-psutil \
6361
python3-psycopg2 \
6462
python3-pyosmium \
63+
python3-uvicorn \
6564
python3-sqlalchemy \
6665
python3-yaml \
6766
&& apt-get clean \
@@ -73,7 +72,7 @@ ENV NOMINATIM_TOKENIZER=icu \
7372
PGUSER=postgres \
7473
PGPASSWORD=change-this-password \
7574
OSM_FILENAME= \
76-
FPM_CONFIG=/etc/php/8.1/fpm/pool.d/www.conf
75+
WEB_CONCURRENCY=1
7776

7877
WORKDIR /nominatim
7978

@@ -86,13 +85,7 @@ COPY --from=build /usr/local/share/nominatim/ /usr/local/share/nominatim/
8685
# copy shell scripts
8786
COPY --chmod=0755 *.sh ./
8887

89-
# fpm settings required for Docker
90-
RUN sed -i '1 i\[global]\nerror_log = /proc/self/fd/2\n' $FPM_CONFIG \
91-
&& sed -i 's|;access.log = log/$pool.access.log|access.log = /proc/self/fd/2|' $FPM_CONFIG \
92-
&& sed -i 's|listen = /run/php/php8.1-fpm.sock|listen = 9000|' $FPM_CONFIG \
93-
&& ln -s /usr/sbin/php-fpm8.1 /usr/sbin/php-fpm
94-
9588
ENTRYPOINT [ "./entrypoint.sh" ]
96-
CMD [ "fpm" ]
89+
CMD [ "uvicorn" ]
9790

98-
EXPOSE 9000
91+
EXPOSE 8000

app/entrypoint.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,17 @@ if [ "$1" = 'replication' ]; then
109109
exec nominatim "$@" --threads $PROCESSING_UNITS
110110
fi
111111

112-
# php-fpm
113-
if [ "$1" = 'fpm' ]; then
112+
# uvicorn ASGI
113+
if [ "$1" = 'uvicorn' ]; then
114114
waitForGis
115115
waitForGisDatabase nominatim
116-
nominatim refresh --website --functions
117116

118-
# run in the foreground
119-
exec php-fpm --nodaemonize
117+
# the new server code is bundled within the python library
118+
cd /usr/local/lib/nominatim/lib-python
119+
# uvicorn uses the WEB_CONCURRENCY env variable for multiple worker processes
120+
# modify WEB_CONCURRENCY in docker-compose.yaml
121+
exec python3 -m uvicorn nominatim.server.falcon.server:run_wsgi \
122+
--proxy-headers --host 0.0.0.0 --port 8000 --factory
120123
fi
121124

122125
exec "$@"

deploy/docker-compose-setup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '2'
22

33
services:
44
feed:
5-
image: smithmicro/n7m-app:4.2
5+
image: smithmicro/n7m-app:4.3
66
depends_on:
77
- gis
88
environment:

deploy/docker-compose.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '2'
22

33
services:
44
web:
5-
image: smithmicro/n7m-web:4.2
5+
image: smithmicro/n7m-web:4.3
66
restart: always
77
ports:
88
- "80:80"
@@ -11,16 +11,17 @@ services:
1111
- ui
1212
mem_limit: 100m
1313
ui:
14-
image: smithmicro/n7m-ui:3.2
14+
image: smithmicro/n7m-ui:3.4
1515
restart: always
1616
mem_limit: 100m
1717
app:
18-
image: smithmicro/n7m-app:4.2
18+
image: smithmicro/n7m-app:4.3
1919
restart: always
2020
depends_on:
2121
- gis
2222
environment:
2323
- PGPASSWORD=n7m-geocoding
24+
- WEB_CONCURRENCY=4
2425
gis:
2526
image: postgis/postgis:15-3.3-alpine
2627
restart: always

docker-compose.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: '2'
33
services:
44
web:
55
build: web
6-
image: smithmicro/n7m-web:4.2
6+
image: smithmicro/n7m-web:4.3
77
restart: always
88
ports:
99
- "8080:80"
@@ -13,20 +13,21 @@ services:
1313
mem_limit: 100m
1414
ui:
1515
build: ui
16-
image: smithmicro/n7m-ui:3.2
16+
image: smithmicro/n7m-ui:3.4
1717
restart: always
1818
mem_limit: 100m
1919
app:
2020
build: app
21-
image: smithmicro/n7m-app:4.2
21+
image: smithmicro/n7m-app:4.3
2222
#restart: always
2323
environment:
2424
- PGPASSWORD=n7m-geocoding
25+
- WEB_CONCURRENCY=2
2526
depends_on:
2627
- gis
2728
mem_limit: 200m
2829
feed:
29-
image: smithmicro/n7m-app:4.2
30+
image: smithmicro/n7m-app:4.3
3031
depends_on:
3132
- gis
3233
environment:

ui/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM nginx:1.24-alpine
22

33
# https://nominatim.org/release-docs/latest/admin/Setup-Nominatim-UI/
44

5-
ENV NOMINATIM_UI_VERSION=3.2.12
5+
ENV NOMINATIM_UI_VERSION=3.4.0
66
ENV NOMINATIM_UI_FILENAME=nominatim-ui-$NOMINATIM_UI_VERSION
77
ENV NOMINATIM_APINOMINATIM_API_ENDPOINT_URI=/api/v4/
88
ENV NGINX_HTML_PATH=/usr/share/nginx/html

web/site.conf

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,39 @@ server {
77
# error_log /var/log/nginx/error.log debug;
88
# command: [nginx-debug, '-g', 'daemon off;']
99

10-
# n7m-app - exposing reverse geocoding without an extension
11-
location /api/v4/reverse {
12-
root /nominatim/website;
13-
fastcgi_param SCRIPT_FILENAME "$document_root/reverse.php";
14-
fastcgi_pass app:9000;
15-
include fastcgi_params;
16-
}
17-
# n7m-app - PHP endpoints
10+
# n7m-app - Python endpoint
1811
location /api/v4/ {
19-
root /nominatim/website;
20-
fastcgi_split_path_info ^/api/v4(/.+\.php)()$;
21-
fastcgi_param SCRIPT_FILENAME "$document_root$fastcgi_script_name";
22-
fastcgi_pass app:9000;
23-
include fastcgi_params;
12+
rewrite /api/v4/(.*) /$1 break;
13+
proxy_set_header Host $http_host;
14+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
15+
proxy_set_header X-Forwarded-Proto $scheme;
16+
proxy_set_header Upgrade $http_upgrade;
17+
proxy_set_header Connection $connection_upgrade;
18+
proxy_redirect off;
19+
proxy_buffering off;
20+
proxy_pass http://app:8000;
2421
}
25-
# n7m-app - health endponnt
22+
23+
# n7m-app - Python health endpoint
2624
location /health {
27-
root /nominatim/website;
28-
fastcgi_param SCRIPT_FILENAME "$document_root/status.php";
29-
fastcgi_pass app:9000;
30-
include fastcgi_params;
25+
rewrite /health /status.php break;
26+
proxy_set_header Host $http_host;
27+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28+
proxy_set_header X-Forwarded-Proto $scheme;
29+
proxy_set_header Upgrade $http_upgrade;
30+
proxy_set_header Connection $connection_upgrade;
31+
proxy_redirect off;
32+
proxy_buffering off;
33+
proxy_pass http://app:8000;
3134
}
3235

3336
# n7m-ui
3437
location / {
3538
proxy_pass http://ui;
3639
}
3740
}
41+
42+
map $http_upgrade $connection_upgrade {
43+
default upgrade;
44+
'' close;
45+
}

0 commit comments

Comments
 (0)