Skip to content

Commit dd1f3c2

Browse files
authored
Merge pull request #15 from openimis/database-jsonb-extension
Added jsonb schema extension installation
2 parents 815f20b + 76a7138 commit dd1f3c2

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@ FROM postgres:13-alpine
33
# Script to detect whether the database has finished initializing
44
COPY ["true_isready.sh", "/usr/local/bin/"]
55
COPY ["database scripts/00_dump.sql", "database scripts/0[2345]_*.sql", "database scripts/demo_db.sql", "/docker-entrypoint-initdb.d/"]
6+
7+
# Install https://github.com/gavinwahl/postgres-json-schema/
8+
# extension that allows validation of jsonb fields against jsonschema
9+
COPY ["install_postgres_json_schema_extension.sh", "install_postgres_json_schema_extension.sh"]
10+
RUN chmod u+x install_postgres_json_schema_extension.sh
11+
RUN ./install_postgres_json_schema_extension.sh
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
apk add --update make
3+
apk add --update git
4+
5+
# Clone the repository
6+
git clone https://github.com/gavinwahl/postgres-json-schema/
7+
8+
apk add libpq-dev
9+
# Move into the directory
10+
cd postgres-json-schema
11+
12+
# Build the extension
13+
make & make install
14+
15+
16+
apk add postgresql-client
17+
18+
/bin/mkdir -p '/usr/local/share/postgresql/extension'
19+
20+
chmod 666 /usr/local/share/postgresql/extension/postgres-json-schema.control
21+
# Add extension to PostgreSQL
22+
# Assuming you're operating in the psql shell
23+
psql -U $POSTGRES_USER -d $POSTGRES_DB -c "CREATE EXTENSION \"postgres-json-schema\";"

0 commit comments

Comments
 (0)