Last active
June 16, 2023 14:11
-
-
Save deangrant/78e985bb388156762a9cd76047148982 to your computer and use it in GitHub Desktop.
Contains code snippets for installing and configuring pg_cron within a container, for full details see https://github.com/citusdata/pg_cron.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dockerfile for building a PostgreSQL container image. | |
FROM postgres:14.7-bullseye | |
# Copies the init.sql file from the local './postgres'directory to the | |
# '/docker-entrypoint-initdb.d' directory in the container. This directory | |
# is where PostgreSQL will look for initialization scripts to run when the | |
# container is first started. | |
ADD ./postgres/init.sql /docker-entrypoint-initdb.d/init.sql | |
# Retrieves new list of packages and installs the pg_cron extension | |
# for PostgreSQL. | |
RUN apt-get update && \ | |
apt-get install -y postgresql-14-cron && \ | |
# Starts the pg_cron background worker process, specifies the database and | |
# timezone in which the background worker will run at startup, and specifies | |
# the pg_cron extension as a shared library to load. | |
CMD ["-c", "shared_preload_libraries=pg_cron", \ | |
"-c", "cron.database_name=postgres", \ | |
"-c", "cron.timezone=UTC"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Creates the pg_cron extension. | |
CREATE EXTENSION pg_cron; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment