From 5d5e882e560c153eed6e5320fc13a552d146e626 Mon Sep 17 00:00:00 2001 From: medina5 Date: Sun, 5 Oct 2025 19:16:58 +0200 Subject: [PATCH] postgresql 18 --- Dockerfile | 28 +++++++++++++------ docker-entrypoint-initdb.d/1_initdb.sql | 2 ++ json/json.sql | 37 +++++++++++++------------ 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 40285b6..e082739 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:trixie AS build-essential +FROM debian:forky AS build-essential RUN set -eux; \ apt-get update; \ @@ -10,6 +10,7 @@ RUN set -eux; \ build-essential \ cmake \ checkinstall \ + ca-certificates \ ; FROM build-essential AS build-pgdev @@ -17,21 +18,18 @@ FROM build-essential AS build-pgdev RUN set -eux; \ apt-get update; \ apt-get install -y --no-install-recommends \ - postgresql-server-dev-17 \ + postgresql-server-dev-18 \ ; # ============================================================================= # pgTAP # -FROM debian:trixie AS pgtap +FROM build-pgdev AS pgtap # Installer les outils nécessaires pour compiler pgTAP RUN apt-get update && \ apt-get install -y --no-install-recommends \ git \ - build-essential \ - ca-certificates \ - postgresql-server-dev-17 \ make # Cloner et compiler pgTAP @@ -96,7 +94,7 @@ RUN checkinstall -D --install=no --fstrans=no --backup=no --pakdir=/tmp --nodoc # FROM build-pgdev AS pgvector -ARG pgvector_release=0.6.2 +ARG pgvector_release=0.8.1 ADD "https://github.com/pgvector/pgvector/archive/refs/tags/v${pgvector_release}.tar.gz" \ /tmp/pgvector.tar.gz @@ -115,7 +113,7 @@ RUN checkinstall -D --install=no --fstrans=no --backup=no --pakdir=/tmp \ # ============================================================================= # Étape 3 : image finale PostgreSQL propre # -FROM postgres:17.6 +FROM postgres:18-trixie RUN set -eux; \ apt-get update; \ @@ -124,15 +122,27 @@ RUN set -eux; \ sed -i '/fr_FR.UTF-8/s/^# //' /etc/locale.gen; \ locale-gen +RUN localedef -i fr_FR -c -f UTF-8 -A /usr/share/locale/locale.alias fr_FR.UTF-8 + ENV TZ=Europe/Paris ENV LANG=fr_FR.UTF-8 ENV LANGUAGE=fr_FR:fr ENV LC_ALL=fr_FR.UTF-8 +ENV POSTGIS_MAJOR=3 +ENV POSTGIS_VERSION=3.6.0+dfsg-1.pgdg13+1 + RUN set -eux; \ apt-get update; \ + apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR; \ apt-get install -y --no-install-recommends \ - postgresql-postgis + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-18-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-18-postgis-$POSTGIS_MAJOR-scripts; \ + rm -rf /var/lib/apt/lists/* # Copier uniquement les fichiers installés depuis le builder COPY --from=pgtap /pgtap-dist/ / diff --git a/docker-entrypoint-initdb.d/1_initdb.sql b/docker-entrypoint-initdb.d/1_initdb.sql index 7efd6b3..671cb44 100644 --- a/docker-entrypoint-initdb.d/1_initdb.sql +++ b/docker-entrypoint-initdb.d/1_initdb.sql @@ -1,3 +1,5 @@ +select * from pg_available_extensions; + create extension if not exists ltree; create extension if not exists pgtap; create extension if not exists postgis; diff --git a/json/json.sql b/json/json.sql index 5547aea..5c343c9 100644 --- a/json/json.sql +++ b/json/json.sql @@ -1,22 +1,25 @@ -create table item ( - id bigint primary key, - caracteristiques jsonb -); - DO $$ DECLARE - f TEXT; + f TEXT; BEGIN - FOR f IN SELECT pg_catalog.pg_ls_dir('/tmp/json') - LOOP - IF right(f, 5) = '.json' THEN - INSERT INTO item (id, caracteristiques) - VALUES ( - replace(f, '.json','')::bigint, - pg_read_file('/tmp/json/' || f)::jsonb - ) - ON CONFLICT (id) DO UPDATE SET caracteristiques = EXCLUDED.caracteristiques; - END IF; - END LOOP; + FOR f IN SELECT pg_catalog.pg_ls_dir('/tmp/json') + LOOP + IF right(f, 5) = '.json' THEN + BEGIN + RAISE NOTICE 'Import du fichier : %', f; + + INSERT INTO item (id, caracteristiques) + VALUES ( + replace(f, '.json','')::bigint, + pg_read_file('/tmp/json/' || f)::jsonb + ) + ON CONFLICT (id) DO UPDATE + SET caracteristiques = EXCLUDED.caracteristiques; + + EXCEPTION WHEN OTHERS THEN + RAISE WARNING 'Erreur lors de l''import du fichier % : %', f, SQLERRM; + END; + END IF; + END LOOP; END; $$ LANGUAGE plpgsql;