Skip to content

test pg_cron #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions 16/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions 16/docker-entrypoint-initdb.d/0001-pg_cron.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions 16/setup-pg-cron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

cat <<EOT >> /var/lib/postgresql/data/postgresql.conf
shared_preload_libraries='pg_cron'
cron.database_name='postgres'
EOT