This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
forked from paunin/PostDock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Postgres-9.6.Dockerfile
96 lines (76 loc) · 3.75 KB
/
Postgres-9.6.Dockerfile
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
FROM postgres:9.6
ARG POSTGRES_VERSION=9.6
RUN apt-get update --fix-missing && \
apt-get install -y postgresql-server-dev-$POSTGRES_VERSION postgresql-$POSTGRES_VERSION-repmgr wget openssh-server
# Inherited variables
# ENV POSTGRES_PASSWORD monkey_pass
# ENV POSTGRES_USER monkey_user
# ENV POSTGRES_DB monkey_db
# Name of the cluster you want to start
ENV CLUSTER_NAME pg_cluster
# special repmgr db for cluster info
ENV REPLICATION_DB replication_db
ENV REPLICATION_USER replication_user
ENV REPLICATION_PASSWORD replication_pass
ENV REPLICATION_PRIMARY_PORT 5432
# Host for replication (REQUIRED, NO DEFAULT)
# ENV REPLICATION_PRIMARY_HOST
# Integer number of node (REQUIRED, NO DEFAULT)
# ENV NODE_ID 1
# Node name (REQUIRED, NO DEFAULT)
# ENV NODE_NAME node1
# (default: `hostname` of the node)
# ENV CLUSTER_NODE_NETWORK_NAME null
# priority on electing new master
ENV NODE_PRIORITY 100
# ENV CONFIGS "listen_addresses:'*'"
# in format variable1:value1[,variable2:value2[,...]]
# used for pgpool.conf file
ENV PARTNER_NODES ""
# List (comma separated) of all nodes in the cluster, it allows master to be adaptive on restart
# (can act as a new standby if new master has been already elected)
ENV MASTER_ROLE_LOCK_FILE_NAME $PGDATA/master.lock
# File will be put in $MASTER_ROLE_LOCK_FILE_NAME when:
# - node starts as a primary node/master
# - node promoted to a primary node/master
# File does not exist
# - if node starts as a standby
ENV STANDBY_ROLE_LOCK_FILE_NAME $PGDATA/standby.lock
# File will be put in $STANDBY_ROLE_LOCK_FILE_NAME when:
# - event repmgrd_failover_follow happened
# contains upstream NODE_ID
# that basically used when standby changes upstream node set by default
ENV REPMGR_WAIT_POSTGRES_START_TIMEOUT 90
# For how long in seconds repmgr will wait for postgres start on current node
# Should be big enough to perform post replication start which might take from a minute to a few
ENV USE_REPLICATION_SLOTS 1
# Use replication slots to make sure that WAL files will not be removed without beein synced to replicas
# Recomended(not required though) to put 0 for replicas of the second and deeper levels
ENV CLEAN_OVER_REWIND 0
# Clean $PGDATA directory before start standby and not try to rewind
ENV SSH_ENABLE 0
# If you need SSH server running on the node
#### Advanced options ####
ENV REPMGR_PID_FILE /tmp/repmgrd.pid
ENV WAIT_SYSTEM_IS_STARTING 5
ENV STOPPING_LOCK_FILE /tmp/stop.pid
ENV REPLICATION_LOCK_FILE /tmp/replication
ENV STOPPING_TIMEOUT 15
ENV CONNECT_TIMEOUT 2
ENV RECONNECT_ATTEMPTS 3
ENV RECONNECT_INTERVAL 5
ENV MASTER_RESPONSE_TIMEOUT 20
ENV LOG_LEVEL INFO
ENV CHECK_PGCONNECT_TIMEOUT 10
ENV REPMGR_SLOT_NAME_PREFIX repmgr_slot_
COPY ./pgsql/bin /usr/local/bin/cluster
RUN chmod -R +x /usr/local/bin/cluster
RUN ln -s /usr/local/bin/cluster/functions/* /usr/local/bin/
COPY ./pgsql/configs /var/cluster_configs
ENV NOTVISIBLE "in users profile"
COPY ./ssh /home/postgres/.ssh
EXPOSE 22
EXPOSE 5432
VOLUME /var/lib/postgresql/data
USER root
CMD ["/usr/local/bin/cluster/entrypoint.sh"]