diff --git a/16/Dockerfile b/16/Dockerfile index c787a85..3e2924b 100644 --- a/16/Dockerfile +++ b/16/Dockerfile @@ -27,3 +27,17 @@ COPY --from=builder /opt/bitnami/postgresql/lib/*.so /opt/bitnami/postgresql/lib COPY --from=builder /opt/bitnami/postgresql/share/extension /opt/bitnami/postgresql/share/extension USER 1001 + + +# New settings +FROM docker.io/library/postgres +RUN apt-get update && \ + apt-get install -y \ + cron \ + postgresql-`postgres -V | awk '{print $3}' | awk -F. '{print $1}'`-cron + +COPY setup-pg-cron.sh /docker-entrypoint-initdb.d/ + + + +# docker run -e POSTGRES_PASSWORD=password -p 5432:5432 --rm -it ametnes/postgresql:16-debian-12 \ No newline at end of file diff --git a/16/docker-entrypoint-initdb.d/0001-pg_cron.sh b/16/docker-entrypoint-initdb.d/0001-pg_cron.sh new file mode 100644 index 0000000..7b4b5ea --- /dev/null +++ b/16/docker-entrypoint-initdb.d/0001-pg_cron.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# We need to append a line to the end of postgresql.conf to load the cron shared library +echo -e "shared_preload_libraries='cron'\ncron.database_name = 'postgres'" >> ${PGDATA}/postgresql.conf + +# Dump the postgres.conf file for debugging +cat ${PGDATA}/postgresql.conf + +# Execute pg_ctl restart so that postgres reloads the updated config file +pg_ctl restart \ No newline at end of file diff --git a/16/setup-pg-cron.sh b/16/setup-pg-cron.sh new file mode 100644 index 0000000..75ef8fd --- /dev/null +++ b/16/setup-pg-cron.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cat <> /var/lib/postgresql/data/postgresql.conf +shared_preload_libraries='pg_cron' +cron.database_name='postgres' +EOT \ No newline at end of file