PostGIS build

오픈소스·2023년 12월 17일
0
post-thumbnail

https://postgis.net/documentation/getting_started/

  • CREATE EXTENSION postgis;
    • https://hub.docker.com/_/postgres 16.0 공식 image에서 작동하지 않았다.
      $ psql -U [username] -d [database_name] -h [hostname] -p [port_number]
      test=# CREATE EXTENSION postgis;
      ERROR:  extension "postgis" already exists
      test=# SELECT * FROM pg_available_extensions WHERE name = 'postgis';
       name | default_version | installed_version | comment 
      ------+-----------------+-------------------+---------
      (0 rows)

https://github.com/postgis/docker-postgis/tree/master/16-3.4

  • Download files

    • Dockerfile
    • initdb-postgis.sh
    • update-postgis.sh
    version: "3"
    
    services:
        local_db:
            env_file: .env
            container_name: postgis_local_db
            image: postgis:16-3.4
            build:
                context: .
                dockerfile: Dockerfile
            restart: always
            ports:
                - 5432:5432
            environment:
                - POSTGRES_USER=${DATABASE_USER}
                - POSTGRES_PASSWORD=${DATABASE_PASSWORD}
                - POSTGRES_DB=${DATABASE_NAME}
            volumes:
                - ./local/postgresql/data/:/var/lib/postgresql/data/

    빌드중 에러가 발생한다면, postgres 관련 docker images 를 삭제한다.
    (https://stackoverflow.com/questions/62473932/at-least-one-invalid-signature-was-encountered)

    test=# SELECT * FROM pg_available_extensions WHERE name = 'postgis';
      name   | default_version | installed_version |                          comment                           
    ---------+-----------------+-------------------+------------------------------------------------------------
     postgis | 3.4.1           | 3.4.1             | PostGIS geometry and geography spatial types and functions
    (1 row)

0개의 댓글