{# containers /current variables}

Install PostGIS for AlloyDB Omni

Select a documentation version:

This page describes how to manually add the PostGIS extension to an existing AlloyDB Omni installation. The PostGIS extension enables storing, indexing, and querying geospatial data.

You can install PostGIS using either of the following methods:

  • Use Debian options in the Docker or Podman CLI. Docker relies on a daemon and requires root privileges for most operations, while Podman is daemonless and rootless.
  • Use Red Hat Universal Base Images (UBI). UBI container base operating system images are built from parts of Red Hat Enterprise Linux (RHEL).

Before you begin

Install AlloyDB Omni on your system.

Add PostGIS to your AlloyDB Omni installation

To add the PostGIS extension to your AlloyDB Omni installation, follow these steps:

  1. Find your installed AlloyDB Omni version labels:

    Docker

     docker  
    run  
    --rm  
    -it  
    google/alloydbomni  
    cat  
    VERSION.txt 
    

    Podman

     podman  
    run  
    --rm  
    -it  
    google/alloydbomni  
    cat  
    VERSION.txt 
    

    The output is similar to the following:

     AlloyDB Omni version: 16.8.0 
    

    Take note of the AlloyDB Omni version number because you need it in the next step.

  2. Set the OMNI_VERSION environment variable:

      OMNI_VERSION 
     = 
     VERSION 
     
    

    Replace VERSION with the complete database server version from the previous step, for example, 16.8.0 .

  3. Create a new AlloyDB Omni container that includes PostGIS:

    Linux

     mkdir  
    ~/alloydb-omni-postgis
    
    tee  
    -a  
    ~/alloydb-omni-postgis/Dockerfile << 
    EOF
    ARG  
    OMNI_VERSION  
    FROM  
    google/alloydbomni: OMNI_VERSION 
      
    RUN  
    apt-get  
    update && 
     \ 
      
    apt-get  
    install  
    -y  
    --no-install-recommends  
     \ 
      
    postgresql-16-postgis-3 && 
     \ 
      
    apt-get  
    purge  
    -y  
    --auto-remove && 
     \ 
      
    rm  
    -rf  
    /var/lib/apt/lists/*  
    EOF  
     cd 
      
    ~/alloydb-omni-postgis  
    sudo  
    docker  
    build  
    --build-arg  
     OMNI_VERSION 
     = 
     $ OMNI_VERSION 
     
      
    --tag  
    google/alloydbomni-with-postgis: OMNI_VERSION 
      
    . 
    

    MacOS

     mkdir  
    ~/alloydb-omni-postgis
    
    tee  
    -a  
    ~/alloydb-omni-postgis/Dockerfile << 
    EOF
    ARG  
    OMNI_VERSION
    FROM  
    google/alloydbomni: OMNI_VERSION 
    RUN  
    apt-get  
    update && 
     \ 
      
    apt-get  
    install  
    -y  
    --no-install-recommends  
     \ 
      
    postgresql-16-postgis-3 && 
     \ 
      
    apt-get  
    purge  
    -y  
    --auto-remove && 
     \ 
      
    rm  
    -rf  
    /var/lib/apt/lists/*  
    EOF  
     cd 
      
    ~/alloydb-omni-postgis  
    sudo  
    docker  
    build  
    --build-arg  
     OMNI_VERSION 
     = 
     $ OMNI_VERSION 
     
      
    --tag  
    google/alloydbomni-with-postgis: $ OMNI_VERSION 
     
      
    .  
     ``` 
     
    
  4. Create a new container with AlloyDB Omni named my-omni-postgis :

    Docker

     docker  
    build  
    -t  
    google/alloydbomni-with-postgis:latest
    docker  
    run  
    --name  
    my-omni-postgis  
    -e  
     POSTGRES_PASSWORD 
     = 
     NEW_PASSWORD 
      
    -d  
    google/alloydbomni-with-postgis: OMNI_VERSION 
     
    

    Podman

     podman  
    run  
    --name  
    my-omni-postgis  
    -e  
     POSTGRES_PASSWORD 
     = 
     NEW_PASSWORD 
      
    -d  
    google/alloydbomni-with-postgis: OMNI_VERSION 
     
    
  5. Connect to your database with the PostGIS extension:

     docker  
     exec 
      
    -it  
    my-omni-postgis  
    psql  
    -h  
    localhost  
    -U  
    postgres 
    
  6. Enable PostGIS:

     CREATE  
    EXTENSION  
    IF  
    NOT  
    EXISTS  
    POSTGIS ; 
    SELECT  
    postgis_full_version () 
     ; 
     
    

    The output looks similar to the following:

     postgres=# SELECT postgis_full_version();
    postgis_full_version
    --------------------------------------------------------------------------------------------------------------------------------
    POSTGIS="3.3.2 4975da8" [EXTENSION] PGSQL="150" GEOS="3.11.1-CAPI-1.17.1" PROJ="9.1.1" LIBXML="2.9.14" LIBJSON="0.16" LIBPROTOBUF="1.4.1" WAGYU="0.5.0 (Internal)"
    (1 row) 
    
Design a Mobile Site
View Site in Mobile | Classic
Share by: