-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
155 lines (119 loc) · 4.54 KB
/
Dockerfile
File metadata and controls
155 lines (119 loc) · 4.54 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
##############################
# base image for all flavors #
##############################
FROM rockylinux/rockylinux:9-ubi AS base
ARG PACKAGE_RELEASE_CHANNEL=""
ARG POSTGRES_USER_ID="26"
COPY docker-entrypoint.sh docker-ensure-initdb.sh /usr/local/bin/
RUN <<EOF
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
useradd -u ${POSTGRES_USER_ID} -m postgres -s /bin/bash
dnf install -y epel-release dnf
dnf config-manager --set-enabled crb
dnf update -y --allowerasing
dnf install -y https://dnf.pgedge.com/reporpm/pgedge-release-latest.noarch.rpm
if [[ -n "${PACKAGE_RELEASE_CHANNEL}" ]]; then
sed -i "s|release|${PACKAGE_RELEASE_CHANNEL}|g" /etc/yum.repos.d/pgedge.repo
fi
mkdir /docker-entrypoint-initdb.d
EOF
##########################
# minimal-flavored image #
##########################
FROM base AS minimal
ARG PACKAGE_LIST_FILE
ARG TARGETARCH
ARG POSTGRES_MAJOR_VERSION
COPY packagelists/${TARGETARCH}/${PACKAGE_LIST_FILE} /usr/share/pgedge/packages.txt
RUN <<EOF
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
xargs dnf install -y < /usr/share/pgedge/packages.txt
dnf clean all
EOF
ENV PGDATA=/var/lib/pgsql/${POSTGRES_MAJOR_VERSION}/data
RUN install --verbose --directory --owner postgres --group postgres --mode 1777 "$PGDATA"
USER postgres
ENV PG_MAJOR=${POSTGRES_MAJOR_VERSION}
ENV PATH=$PATH:/usr/pgsql-${POSTGRES_MAJOR_VERSION}/bin
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
# We set the default STOPSIGNAL to SIGINT, which corresponds to what PostgreSQL
# calls "Fast Shutdown mode" wherein new connections are disallowed and any
# in-progress transactions are aborted, allowing PostgreSQL to stop cleanly and
# flush tables to disk.
#
# See https://www.postgresql.org/docs/current/server-shutdown.html for more details
# about available PostgreSQL server shutdown signals.
#
# See also https://www.postgresql.org/docs/current/server-start.html for further
# justification of this as the default value, namely that the example (and
# shipped) systemd service files use the "Fast Shutdown mode" for service
# termination.
#
STOPSIGNAL SIGINT
#
# An additional setting that is recommended for all users regardless of this
# value is the runtime "--stop-timeout" (or your orchestrator/runtime's
# equivalent) for controlling how long to wait between sending the defined
# STOPSIGNAL and sending SIGKILL.
#
# The default in most runtimes (such as Docker) is 10 seconds, and the
# documentation at https://www.postgresql.org/docs/current/server-start.html notes
# that even 90 seconds may not be long enough in many instances.
EXPOSE 5432
CMD ["postgres"]
###########################
# standard-flavored image #
###########################
FROM base AS standard
ARG PACKAGE_LIST_FILE
ARG TARGETARCH
ARG POSTGRES_MAJOR_VERSION
COPY packagelists/${TARGETARCH}/${PACKAGE_LIST_FILE} /usr/share/pgedge/packages.txt
RUN <<EOF
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
xargs dnf install -y < /usr/share/pgedge/packages.txt
dnf install -y python3-pip-21.3.1-1.el9
pip install 'patroni[etcd,jsonlogger]==4.1.0'
dnf remove -y python3-pip
dnf clean all
EOF
ENV PGDATA=/var/lib/pgsql/${POSTGRES_MAJOR_VERSION}/data
RUN install --verbose --directory --owner postgres --group postgres --mode 1777 "$PGDATA"
USER postgres
ENV PG_MAJOR=${POSTGRES_MAJOR_VERSION}
ENV PATH=$PATH:/usr/pgsql-${POSTGRES_MAJOR_VERSION}/bin
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
# We set the default STOPSIGNAL to SIGINT, which corresponds to what PostgreSQL
# calls "Fast Shutdown mode" wherein new connections are disallowed and any
# in-progress transactions are aborted, allowing PostgreSQL to stop cleanly and
# flush tables to disk.
#
# See https://www.postgresql.org/docs/current/server-shutdown.html for more details
# about available PostgreSQL server shutdown signals.
#
# See also https://www.postgresql.org/docs/current/server-start.html for further
# justification of this as the default value, namely that the example (and
# shipped) systemd service files use the "Fast Shutdown mode" for service
# termination.
#
STOPSIGNAL SIGINT
#
# An additional setting that is recommended for all users regardless of this
# value is the runtime "--stop-timeout" (or your orchestrator/runtime's
# equivalent) for controlling how long to wait between sending the defined
# STOPSIGNAL and sending SIGKILL.
#
# The default in most runtimes (such as Docker) is 10 seconds, and the
# documentation at https://www.postgresql.org/docs/current/server-start.html notes
# that even 90 seconds may not be long enough in many instances.
EXPOSE 5432
CMD ["postgres"]