Skip to content

Commit eb99ebd

Browse files
committed
chore(database): add database extension
1 parent e269938 commit eb99ebd

5 files changed

Lines changed: 19 additions & 6 deletions

File tree

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ FROM registry.drycc.cc/drycc/base:${CODENAME}
33

44
COPY rootfs/usr /usr/
55
COPY rootfs/entrypoint.sh /entrypoint.sh
6-
ENV PYTHON_VERSION="3.11" \
7-
PG_MAJOR=14 \
8-
POSTGRESQL_VERSION="15.3"
6+
ENV PG_MAJOR=15 \
7+
PG_MINOR=3 \
8+
PYTHON_VERSION="3.11"
99

1010
ENV PGDATA /data/${PG_MAJOR}
1111

1212
RUN install-packages gcc \
1313
&& install-stack python $PYTHON_VERSION \
14-
&& install-stack postgresql $POSTGRESQL_VERSION \
14+
&& install-stack postgresql $PG_MAJOR.$PG_MINOR \
1515
&& . init-stack \
1616
&& set -eux; pip3 install --disable-pip-version-check --no-cache-dir psycopg[binary] patroni[kubernetes] 2>/dev/null; set +eux \
1717
&& apt-get purge -y --auto-remove gcc \

charts/database/templates/_helper.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ env:
3838
value: '0.0.0.0:8008'
3939
- name: "DRYCC_DATABASE_INIT_NAMES"
4040
value: "{{.Values.initDatabases}}"
41+
- name: "DRYCC_DATABASE_EXTENSIONS"
42+
value: "{{.Values.databaseExtensions}}"
4143
- name: DRYCC_DATABASE_SUPERUSER
4244
valueFrom:
4345
secretKeyRef:

charts/database/values.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ replicator: "standby"
5656
replicatorPassword: ""
5757
user: ""
5858
password: ""
59-
initDatabases: "controller,passport"
59+
initDatabases: "controller,passport,monitor"
60+
databaseExtensions: "postgis,timescaledb"
6061

6162
global:
6263
# Set the location of Workflow's Object Storage

rootfs/entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ restapi:
2626
connect_address: '${PATRONI_KUBERNETES_POD_IP}:8008'
2727
postgresql:
2828
data_dir: '${PGDATA}'
29+
parameters:
30+
timescaledb.license: 'timescale'
31+
shared_preload_libraries: 'auto_explain,timescaledb,pg_stat_statements'
2932
connect_address: '${PATRONI_KUBERNETES_POD_IP}:5432'
3033
authentication:
3134
superuser:

rootfs/usr/share/scripts/patroni/post_init.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ set -Eeu
44
if [[ ( -n "$DRYCC_DATABASE_USER") && ( -n "$DRYCC_DATABASE_PASSWORD")]]; then
55
echo "Creating user ${DRYCC_DATABASE_USER}"
66
psql "$1" -w -c "create user ${DRYCC_DATABASE_USER} WITH LOGIN ENCRYPTED PASSWORD '${DRYCC_DATABASE_PASSWORD}'"
7-
87
for dbname in ${DRYCC_DATABASE_INIT_NAMES//,/ }
98
do
109
echo "Creating database ${dbname}"
1110
psql "$1" -w -c "CREATE DATABASE ${dbname} OWNER ${DRYCC_DATABASE_USER}"
11+
for extension in ${DRYCC_DATABASE_EXTENSIONS//,/ }
12+
do
13+
echo "Creating extension ${extension}"
14+
psql "$1" -w << EOF
15+
\c ${dbname};
16+
create extension ${extension};
17+
EOF
18+
done
1219
done
1320
else
1421
echo "Skipping user creation"

0 commit comments

Comments
 (0)