-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.postgres
More file actions
46 lines (36 loc) · 2.26 KB
/
Copy pathDockerfile.postgres
File metadata and controls
46 lines (36 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# syntax=docker/dockerfile:1.7
ARG POSTGRES_VERSION=18.6-trixie
ARG PG_CRON_VERSION=1.6.7
FROM postgres:${POSTGRES_VERSION} AS pg-cron-builder
ARG PG_CRON_VERSION
ARG PG_CRON_SHA256=d950bc29155f31017567e23a31d268ff672e98276c0e9d062512fb7870351f03
RUN apt-get update \
&& apt-get install --yes --no-install-recommends ca-certificates curl gcc libc6-dev make postgresql-server-dev-18 \
&& curl --fail --location --silent --show-error \
"https://github.com/citusdata/pg_cron/archive/refs/tags/v${PG_CRON_VERSION}.tar.gz" \
--output /tmp/pg_cron.tar.gz \
&& echo "${PG_CRON_SHA256} /tmp/pg_cron.tar.gz" | sha256sum --check --strict \
&& mkdir /tmp/pg_cron \
&& tar --extract --gzip --file /tmp/pg_cron.tar.gz --strip-components=1 --directory /tmp/pg_cron \
&& make --directory /tmp/pg_cron \
&& make --directory /tmp/pg_cron install DESTDIR=/opt/pg_cron
FROM postgres:${POSTGRES_VERSION}
ARG PG_CRON_VERSION
# Bake the database name into the image. The Postgres entrypoint script
# reads $POSTGRES_DB and creates that database on first boot, so bare
# `docker run` users get an `openblog` DB automatically. This is paired
# with `cron.database_name=openblog` in the CMD below — both are required
# for pg_cron to allow `CREATE EXTENSION pg_cron` from the right DB.
ENV POSTGRES_DB=openblog
LABEL org.opencontainers.image.title="OpenBlog PostgreSQL" \
org.opencontainers.image.description="PostgreSQL with pg_cron for OpenBlog scheduled publishing" \
org.opencontainers.image.source="https://github.com/IamCoder18/OpenBlog" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.version="${PG_CRON_VERSION}"
COPY --from=pg-cron-builder /opt/pg_cron/usr/lib/postgresql/18/lib/pg_cron.so /usr/lib/postgresql/18/lib/pg_cron.so
COPY --from=pg-cron-builder /opt/pg_cron/usr/share/postgresql/18/extension/ /usr/share/postgresql/18/extension/
# `cron.database_name` is locked to `openblog`. To use a different name,
# fork the image and rebuild — `CREATE EXTENSION pg_cron` will otherwise
# refuse to run from any other database. Compose files must NOT override
# this with a different value.
CMD ["postgres", "-c", "shared_preload_libraries=pg_cron", "-c", "cron.database_name=openblog", "-c", "cron.use_background_workers=on"]