-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathDockerfile.release
More file actions
65 lines (56 loc) · 3.02 KB
/
Copy pathDockerfile.release
File metadata and controls
65 lines (56 loc) · 3.02 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright (c) Microsoft Corporation.
# Licensed under the PostgreSQL License.
# pg_durable published image — installs a pre-built Debian package from a
# GitHub release on top of the official PostgreSQL image. Used by the
# "Docker Publish" workflow.
#
# This is a single-stage build (no compilation): the .deb is downloaded by the
# workflow into the build context and installed here. For the source-built CI
# image, see ./Dockerfile.
#
# NOTE: This image is intended for evaluating and learning pg_durable only —
# NOT for production. It enables superuser instances for an out-of-the-box demo
# experience. The extension HTTP egress policy is whatever the released package
# was built with (http-allow-azure-domains).
ARG PG_MAJOR=17
FROM postgres:${PG_MAJOR}-bookworm
# Re-declare after FROM so the value is available in build instructions below.
ARG PG_MAJOR=17
# Directory (relative to the build context) containing the downloaded package.
ARG DEB_DIR=dist
# Install runtime dependencies and the pg_durable package.
# ca-certificates is needed for native-tls HTTPS from df.http(). Installing the
# .deb via apt (rather than `dpkg -i`) lets apt resolve any dependencies the
# package declares, so the build won't break if new runtime deps are added.
COPY ${DEB_DIR}/pg-durable-postgresql-${PG_MAJOR}_*_amd64.deb /tmp/pg_durable.deb
RUN apt-get update && apt-get install -y \
libssl3 \
ca-certificates \
/tmp/pg_durable.deb \
&& rm -rf /var/lib/apt/lists/* /tmp/pg_durable.deb
# Create the extension on first database initialization. The extension is
# always created in the `postgres` database to match the hardcoded
# pg_durable.database GUC below; POSTGRES_DB is intentionally ignored so the
# worker and the extension never target different databases.
RUN mkdir -p /docker-entrypoint-initdb.d && \
printf '%s\n' \
'#!/bin/bash' \
'set -e' \
'psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname postgres <<-EOSQL' \
' CREATE EXTENSION IF NOT EXISTS pg_durable;' \
'EOSQL' \
'echo "pg_durable extension created successfully"' \
> /docker-entrypoint-initdb.d/01-init-pg-durable.sh && \
chmod +x /docker-entrypoint-initdb.d/01-init-pg-durable.sh
# Configure the background worker. enable_superuser_instances lets the default
# postgres superuser run durable functions for a frictionless demo (not a
# production-safe setting).
RUN echo "shared_preload_libraries = 'pg_durable'" >> /usr/share/postgresql/postgresql.conf.sample && \
echo "pg_durable.database = 'postgres'" >> /usr/share/postgresql/postgresql.conf.sample && \
echo "pg_durable.worker_role = 'postgres'" >> /usr/share/postgresql/postgresql.conf.sample && \
echo "pg_durable.enable_superuser_instances = on" >> /usr/share/postgresql/postgresql.conf.sample
# Report container health based on PostgreSQL accepting connections on the
# pg_durable database.
HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=5 \
CMD pg_isready -U postgres -d postgres || exit 1
EXPOSE 5432