Skip to content

Commit 19888fa

Browse files
committed
add init extension script
1 parent c778710 commit 19888fa

File tree

3 files changed

+45
-16
lines changed

3 files changed

+45
-16
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ RUN apt-get update \
2323
&& apt-get autoremove -y \
2424
&& apt-get clean \
2525
&& apt-mark unhold locales \
26-
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
26+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
27+
28+
COPY ./initdb-extensions.sh /docker-entrypoint-initdb.d/20_extensions.sh

README.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
postgresql,postgis docker container with pgvector added
2+
13
# Deploy
24

35
[![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)
@@ -6,20 +8,6 @@
68
ghcr.io/gvkhna/postgis-vector:latest
79
```
810

9-
# After Deploy Initialize Extensions
10-
11-
```sh
12-
$ su - postgres
13-
$ psql
14-
postgres=# CREATE EXTENSION vector;
15-
postgres=# CREATE EXTENSION fuzzystrmatch;
16-
postgres=# CREATE EXTENSION pg_trgm;
17-
postgres=# CREATE EXTENSION pg_uuidv7;
18-
19-
# to verify extensions installed
20-
postgres=# \dx
21-
```
22-
2311
## Build
2412

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

2917
## Minimal Run
3018

31-
```
19+
```sh
3220
podman run -it --name postgis-vector -e POSTGRES_PASSWORD=mysecretpassword -d postgis-vector
3321
podman exec -it postgis-vector bash
22+
23+
##
24+
# To verify extensions installed
25+
##
26+
$ su - postgres
27+
$ psql
28+
postgres=# \dx
29+
30+
List of installed extensions
31+
Name | Version | Schema | Description
32+
------------------------+---------+------------+-------------------------------------------------------------------
33+
fuzzystrmatch | 1.2 | public | determine similarities and distance between strings
34+
pg_trgm | 1.6 | public | text similarity measurement and index searching based on trigrams
35+
pg_uuidv7 | 1.5 | public | pg_uuidv7: create UUIDv7 values in postgres
36+
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
37+
postgis | 3.4.2 | public | PostGIS geometry and geography spatial types and functions
38+
postgis_tiger_geocoder | 3.4.2 | tiger | PostGIS tiger geocoder and reverse geocoder
39+
postgis_topology | 3.4.2 | topology | PostGIS topology spatial types and functions
40+
vector | 0.6.2 | public | vector data type and ivfflat and hnsw access methods
41+
(8 rows)
42+
43+
##
44+
# To list all available extensions
45+
##
46+
postgres=# select * from pg_available_extensions;
47+
3448
```

initdb-extensions.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Load additional extensions into database
6+
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
7+
CREATE EXTENSION IF NOT EXISTS pg_trgm;
8+
ALTER EXTENSION pg_trgm UPDATE;
9+
CREATE EXTENSION IF NOT EXISTS pg_uuidv7;
10+
ALTER EXTENSION pg_uuidv7 UPDATE;
11+
CREATE EXTENSION IF NOT EXISTS vector;
12+
ALTER EXTENSION vector UPDATE;
13+
EOSQL

0 commit comments

Comments
 (0)