I am trying to implement a cron job on my Postgres DB using the pg_cron extension but getting the following error which implies pg_cron extension is not installed on the Postgres:13-alpine image I am using :
Reason: liquibase.exception.DatabaseException: ERROR: could not open extension control file "/usr/local/share/postgresql/extension/pg_cron.control": No such file or directory [Failed SQL: (0) CREATE EXTENSION pg_cron]
My Dockerfile :
FROM openjdk:11-jre-slim
# Non-root user
USER 1984:1984
COPY --chown=1984:1984 target/*.jar app.jar
CMD ["java","-jar","app.jar"]
My docker-compose file :
version: '3'
services:
postgres:
image: postgres:13-alpine
ports:
- "5432:5432"
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: pwd
POSTGRES_DB: db
volumes:
- postgresdata:/var/lib/postgresql/data
volumes:
postgresdata:
AFAIU, I should add the following settings to postgresql.conf
shared_preload_libraries = 'pg_cron' cron.database_name = 'postgres'
but since I am using a packaged Postgres Docker image, I am a bit confused and can't really see how this can be done.
Would you please have any pointers as to how add this pg_cron extension to the alpine image and which changes I have to make to my Dockerfile and docker-compose ?
Thank you.