Skip to content

Commit 8bf34e7

Browse files
authored
feat: Add pgrouting and fix pgcron packages (#32)
* feat: Add pgrouting and pgcron packages * Update Dockerfile * add setup for pgrouting * Update Dockerfile * Update docker file * fix db setup * fix db setup for cron * Dockerfile.pgpool * add maintainer to docker file
1 parent e1aed54 commit 8bf34e7

File tree

6 files changed

+31
-14
lines changed

6 files changed

+31
-14
lines changed

Dockerfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
FROM postgres:17-bullseye
22

3-
ENV POSTGIS_MAJOR 3
4-
ENV POSTGIS_VERSION 3.5.0+dfsg-1.pgdg110+1
5-
ENV POSTGRES_INITDB_ARGS "--data-checksums"
3+
LABEL maintainer="HIPAA Postgres w/ PostGIS Project" \
4+
org.opencontainers.image.description="PostGIS 3.5.0+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 17 bullseye" \
5+
org.opencontainers.image.source="https://github.com/netreconlab/hipaa-postgres/"
6+
7+
ENV POSTGIS_MAJOR=3
8+
ENV POSTGIS_VERSION=3.5.0+dfsg-1.pgdg110+1
9+
ENV POSTGRES_INITDB_ARGS="--data-checksums"
610

711
RUN apt-get update \
812
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
@@ -17,6 +21,7 @@ RUN apt-get update \
1721
postgresql-$PG_MAJOR-set-user \
1822
postgresql-$PG_MAJOR-repack \
1923
postgresql-$PG_MAJOR-cron \
24+
postgresql-$PG_MAJOR-pgrouting \
2025
&& rm -rf /var/lib/apt/lists/* \
2126
&& mkdir -p /docker-entrypoint-initdb.d
2227

@@ -43,4 +48,4 @@ RUN chmod +x /docker-entrypoint-initdb.d/setup-0-pgaudit.sh \
4348
/usr/local/bin/setup-parse-index.sh
4449

4550
USER postgres
46-
CMD ["postgres", "-c", "shared_preload_libraries=pgaudit"]
51+
CMD ["postgres", "-c", "shared_preload_libraries=pg_stat_statements,pgaudit,pg_cron"]

Dockerfile.pgpool

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
FROM postgres:17-bullseye
22

3-
ENV POSTGIS_MAJOR 3
4-
ENV POSTGIS_VERSION 3.5.0+dfsg-1.pgdg110+1
5-
ENV POSTGRES_INITDB_ARGS "--data-checksums"
3+
LABEL maintainer="HIPAA Postgres w/ PostGIS Project" \
4+
org.opencontainers.image.description="PostGIS 3.5.0+dfsg-1.pgdg110+1 spatial database extension and PGPool with PostgreSQL 17 bullseye" \
5+
org.opencontainers.image.source="https://github.com/netreconlab/hipaa-postgres/"
6+
7+
ENV POSTGIS_MAJOR=3
8+
ENV POSTGIS_VERSION=3.5.0+dfsg-1.pgdg110+1
9+
ENV POSTGRES_INITDB_ARGS="--data-checksums"
610

711
RUN apt-get update \
812
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
@@ -20,6 +24,8 @@ RUN apt-get update \
2024
postgresql-$PG_MAJOR-pgaudit \
2125
postgresql-$PG_MAJOR-set-user \
2226
postgresql-$PG_MAJOR-repack \
27+
postgresql-$PG_MAJOR-cron \
28+
postgresql-$PG_MAJOR-pgrouting \
2329
postgresql-$PG_MAJOR-pgpool2\
2430
&& rm -rf /var/lib/apt/lists/* \
2531
&& mkdir -p /docker-entrypoint-initdb.d
@@ -47,5 +53,5 @@ RUN chmod +x /docker-entrypoint-initdb.d/setup-0-pgaudit.sh \
4753
/usr/local/bin/setup-parse-index.sh
4854

4955
USER postgres
50-
CMD ["postgres", "-c", "shared_preload_libraries=pgaudit"]
56+
CMD ["postgres", "-c", "shared_preload_libraries=pg_stat_statements,pgaudit,pg_cron"]
5157
EXPOSE 22

scripts/setup-0-pgaudit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ EOF
88

99
set -e
1010
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
11+
\c template1;
1112
CREATE EXTENSION pgaudit;
1213
ALTER SYSTEM SET pgaudit.log_catalog = off;
1314
ALTER SYSTEM SET pgaudit.log = 'all, -misc';
1415
ALTER SYSTEM SET pgaudit.log_relation = 'on';
1516
ALTER SYSTEM SET pgaudit.log_parameter = 'on';
16-
ALTER SYSTEM SET shared_preload_libraries = 'set-user';
1717
EOSQL
1818

1919
exec "$@"

scripts/setup-3-pg_repack.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
set -e
44
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
5+
\c template1;
56
CREATE EXTENSION pg_repack;
67
EOSQL
78

scripts/setup-4-pgstatstatements.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ track_io_timing = on # Capture read/write stats
77
EOF
88

99
set -e
10-
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "postgres" <<-EOSQL
10+
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
1111
CREATE EXTENSION pg_stat_statements SCHEMA public;
12-
ALTER SYSTEM SET shared_preload_libraries = 'set-user, pg_stat_statements';
1312
EOSQL
1413

1514
exec "$@"

scripts/setup-dbs.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
#!/bin/bash
22

3+
cat >> ${PGDATA}/postgresql.conf <<EOF
4+
cron.database_name = '$POSTGRES_DB'
5+
shared_preload_libraries = 'set-user, pg_stat_statements, pgaudit, pg_cron'
6+
EOF
7+
38
set -e
49
psql -v ON_ERROR_STOP=1 --username "${POSTGRES_USER}" --dbname "${POSTGRES_DB}" <<-EOSQL
510
CREATE USER ${PG_PARSE_USER} LOGIN CONNECTION LIMIT 100 ENCRYPTED PASSWORD '${PG_PARSE_PASSWORD}';
611
CREATE DATABASE ${PG_PARSE_DB} OWNER ${PG_PARSE_USER};
12+
CREATE EXTENSION pg_cron;
713
\c ${PG_PARSE_DB};
8-
CREATE EXTENSION postgis;
9-
CREATE EXTENSION postgis_topology;
10-
CREATE EXTENSION pg_repack;
14+
CREATE EXTENSION IF NOT EXISTS postgis;
15+
CREATE EXTENSION IF NOT EXISTS postgis_topology;
16+
CREATE EXTENSION IF NOT EXISTS pgrouting;
1117
EOSQL
1218

1319
exec "$@"

0 commit comments

Comments
 (0)