Skip to content

Commit

Permalink
add init extension script
Browse files Browse the repository at this point in the history
  • Loading branch information
gvkhna committed Mar 30, 2024
1 parent c778710 commit 19888fa
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ RUN apt-get update \
&& apt-get autoremove -y \
&& apt-get clean \
&& apt-mark unhold locales \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY ./initdb-extensions.sh /docker-entrypoint-initdb.d/20_extensions.sh
44 changes: 29 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
postgresql,postgis docker container with pgvector added

# Deploy

[![Docker](https://github.com/gvkhna/postgis-vector/actions/workflows/publish.yml/badge.svg?branch=main)](https://github.com/gvkhna/postgis-vector/actions/workflows/publish.yml)
Expand All @@ -6,20 +8,6 @@
ghcr.io/gvkhna/postgis-vector:latest
```

# After Deploy Initialize Extensions

```sh
$ su - postgres
$ psql
postgres=# CREATE EXTENSION vector;
postgres=# CREATE EXTENSION fuzzystrmatch;
postgres=# CREATE EXTENSION pg_trgm;
postgres=# CREATE EXTENSION pg_uuidv7;

# to verify extensions installed
postgres=# \dx
```

## Build

```sh
Expand All @@ -28,7 +16,33 @@ podman build -t postgis-vector .

## Minimal Run

```
```sh
podman run -it --name postgis-vector -e POSTGRES_PASSWORD=mysecretpassword -d postgis-vector
podman exec -it postgis-vector bash

##
# To verify extensions installed
##
$ su - postgres
$ psql
postgres=# \dx

List of installed extensions
Name | Version | Schema | Description
------------------------+---------+------------+-------------------------------------------------------------------
fuzzystrmatch | 1.2 | public | determine similarities and distance between strings
pg_trgm | 1.6 | public | text similarity measurement and index searching based on trigrams
pg_uuidv7 | 1.5 | public | pg_uuidv7: create UUIDv7 values in postgres
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
postgis | 3.4.2 | public | PostGIS geometry and geography spatial types and functions
postgis_tiger_geocoder | 3.4.2 | tiger | PostGIS tiger geocoder and reverse geocoder
postgis_topology | 3.4.2 | topology | PostGIS topology spatial types and functions
vector | 0.6.2 | public | vector data type and ivfflat and hnsw access methods
(8 rows)

##
# To list all available extensions
##
postgres=# select * from pg_available_extensions;

```
13 changes: 13 additions & 0 deletions initdb-extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

# Load additional extensions into database
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE EXTENSION IF NOT EXISTS pg_trgm;
ALTER EXTENSION pg_trgm UPDATE;
CREATE EXTENSION IF NOT EXISTS pg_uuidv7;
ALTER EXTENSION pg_uuidv7 UPDATE;
CREATE EXTENSION IF NOT EXISTS vector;
ALTER EXTENSION vector UPDATE;
EOSQL

0 comments on commit 19888fa

Please sign in to comment.