PG-10-Extensions

PG-10-Extensions

Posted by laohuang on Wednesday, June 25, 2025

配置PG-10 的postgis 和 pg_jieba 插件 Dockerfile:

FROM postgres:10-bullseye

RUN sed -i 's/\w*.debian.org/repo.huaweicloud.com/g' /etc/apt/sources.list && \
    echo "deb https://repo.huaweicloud.com/postgresql/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
    apt-get update -y && \
    apt-get install wget curl git cmake  g++ -y && \
    wget --quiet -O - https://repo.huaweicloud.com/postgresql/repos/apt/ACCC4CF8.asc |  apt-key add - && \
    apt-get update -y && \
    apt-get install postgresql-10-postgis-3 postgresql-server-dev-10 postgis -y && \
    git clone https://github.com/jaiminpan/pg_jieba && \
    cd pg_jieba && \
    git submodule update --init --recursive && \
    mkdir build && \
    cd build && \
    cmake  -DCMAKE_CXX_FLAGS="-Wall -std=c++11"   -DCMAKE_PREFIX_PATH=/usr/include/postgresql/10/server/   .. && \
    make && \
    make install && \
    apt-get clean && \
    cd ../../ && rm -rf pg_jieba  /var/lib/apt/lists/*

RUN echo "CREATE EXTENSION postgis;" > /docker-entrypoint-initdb.d/init-postgis.sql && \
    echo "CREATE EXTENSION pg_jieba;" > /docker-entrypoint-initdb.d/init-jieba.sql
CREATE EXTENSION postgis;
CREATE EXTENSION pg_jieba;

SELECT PostGIS_Version();

\dx
                                 List of installed extensions
   Name   | Version |   Schema   |                        Description
----------+---------+------------+------------------------------------------------------------
 pg_jieba | 1.1.1   | public     | a parser for full-text search of Chinese
 plpgsql  | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis  | 3.2.3   | public     | PostGIS geometry and geography spatial types and functions
(3 rows)

「真诚赞赏,手留余香」

LaoHuang Blog

真诚赞赏,手留余香

使用微信扫描二维码完成支付