From c46903858018b91541446bdc323b3d362b4fd8ef Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Wed, 23 Sep 2026 15:56:05 +0300 Subject: [PATCH] Update libpostal base image to Node 22/Debian bookworm - Bump base image from node:18-bullseye to node:22-bookworm; Node 18 reached EOL in April 2025. - Swap the now-removed `python` transitional package for `python-is-python3` on bookworm. - Wrap the libpostal clone/build/install in a retry loop: its build fetches ~2GB of language model data as GitHub Release assets via 12 parallel curl workers, which intermittently trips GitHub's abuse/rate limiting and previously required manual, error-prone local rebuilds. - Bump pelias-logger to ^2.0.0 to match the version used by all the HSL importer forks (pelias-schema, openstreetmap, pelias-vrk, etc.); its only breaking change is requiring Node >=22. - Pin node-postal to 1.3.0 via yarn resolutions: the previously resolved 1.1.2 (transitive via pelias-text-analyzer) used a V8 API (Object::CreationContext) removed in the V8 version bundled with Node 22, which broke the native addon build. Verified locally: - hsldevcom/libpostal:test built successfully. - pelias-api image builds and boots on the new base with no native addon errors. - Ran 12 real searches (autocomplete/search/reverse) against a pulled hsldevcom/pelias-data-container:latest (today's build, real ES 7.16.2 + full dataset - all returned HTTP 200 with correct results. - Pushed the rebuilt base image to hsldevcom/libpostal:latest on Docker Hub. Pre-existing jshint errors in controller/search.js, middleware/confidenceScoreDT.js, middleware/translate.js are unrelated to this change and left untouched. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> EOF ) --- Dockerfile.base | 34 +++++++++++++++++++++++++--------- package.json | 5 ++++- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/Dockerfile.base b/Dockerfile.base index 06b4efed..7128587b 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -1,4 +1,4 @@ -FROM node:18-bullseye +FROM node:22-bookworm # This dockerfile creates a base image, which contains all libpostal components. # The actual ci build for pelias api does not run error sensitive and @@ -9,14 +9,30 @@ FROM node:18-bullseye # install libpostal RUN apt-get update RUN echo 'APT::Acquire::Retries "20";' >> /etc/apt/apt.conf -RUN apt-get install -y --no-install-recommends git curl make libsnappy-dev autoconf automake libtool python pkg-config +RUN apt-get install -y --no-install-recommends git curl make libsnappy-dev autoconf automake libtool python-is-python3 pkg-config RUN mkdir -p /mnt/data -RUN git clone --single-branch https://github.com/openvenues/libpostal \ - && cd libpostal \ - && ./bootstrap.sh \ - && ./configure --datadir=/mnt/data \ - && make -j4 \ - && make install \ - && ldconfig +# libpostal's build fetches its language model data as release assets straight from +# github.com via several parallel curl workers; that fan-out intermittently trips +# GitHub's abuse/rate limiting and surfaces as spurious TLS/connection errors, so retry +# the whole clone+build+install a few times before giving up. +RUN set -e; \ + for i in 1 2 3 4 5; do \ + rm -rf libpostal && \ + git clone --single-branch https://github.com/openvenues/libpostal \ + && cd libpostal \ + && ./bootstrap.sh \ + && ./configure --datadir=/mnt/data \ + && make -j4 \ + && make install \ + && ldconfig \ + && break; \ + cd /; \ + if [ "$i" -eq 5 ]; then \ + echo "Failed to build libpostal after $i attempts" >&2; \ + exit 1; \ + fi; \ + echo "libpostal build failed (attempt $i), retrying..." >&2; \ + sleep 5; \ + done diff --git a/package.json b/package.json index 3d8582c3..9fc2a979 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,9 @@ "license": "MIT", "main": "index.js", "bin": "./bin/start", + "resolutions": { + "node-postal": "1.3.0" + }, "scripts": { "ciao": "node node_modules/ciao/bin/ciao -c test/ciao.json test/ciao", "coverage": "node_modules/.bin/istanbul cover test/unit/run.js", @@ -54,7 +57,7 @@ "pelias-categories": "^1.2.0", "pelias-config": "^4.5.0", "pelias-labels": "^1.8.0", - "pelias-logger": "^1.2.0", + "pelias-logger": "^2.0.0", "pelias-microservice-wrapper": "^1.7.0", "pelias-model": "^7.0.0", "pelias-parser": "1.38.0",