Last active
September 13, 2016 20:36
-
-
Save psychotechnik/5807792d1576cb565a9a6168e17572a3 to your computer and use it in GitHub Desktop.
pg replication cluster docker related files
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
version: '2' | |
services: | |
pg1: | |
#image: pkalinsky/pg1 | |
build: pg1 | |
env_file: env_vars/pg1_vars.env | |
#ports: | |
# - 5437:5432 | |
#restart: always | |
#volumes: | |
# - /var/local/docker_volumes/pg-docker/pg1:/usr/lib/postgresql/9.5/main | |
pg2: | |
#image: pkalinsky/pg2 | |
build: pg2 | |
env_file: env_vars/pg2_vars.env | |
depends_on: | |
- pg1 | |
#ports: | |
# - 5438:5432 | |
#restart: always | |
#volumes: | |
# - /var/local/docker_volumes/pg-docker/pg2:/usr/lib/postgresql/9.5/main | |
#pgbouncer: | |
# image: pkalinsky/pgbouncer | |
# env_file: env_vars/pgbouncer_vars.env | |
#depends_on: | |
# - pg1, pg2 | |
#restart: always |
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
FROM pkalinsky/pg_base:latest | |
MAINTAINER philip.kalinsky@eloquentbits.com | |
ENV PG_VERSION=9.5 \ | |
UBUNTU_RELEASE=xenial \ | |
PG_DATA_DIR=/var/lib/postgresql/${PG_VERSION}/main \ | |
PG_ETC_DIR=/etc/postgresql/${PG_VERSION}/main \ | |
PG_STANDBY_NODE_ID=2 PG_MASTER_NODE_ID=1 \ | |
PG_SSH_DIR=/var/lib/postgresql/.ssh | |
# Clean up APT when done. | |
#RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
# set up ssh | |
RUN mkdir -p ${PG_SSH_DIR} | |
ADD pg${PG_MASTER_NODE_ID}_key ${PG_SSH_DIR}/id_rsa | |
ADD pg${PG_STANDBY_NODE_ID}_key.pub /tmp/ | |
RUN cat /tmp/pg${PG_STANDBY_NODE_ID}_key.pub >> ${PG_SSH_DIR}/authorized_keys && \ | |
chown postgres:postgres -R ${PG_SSH_DIR} | |
#ssh-keyscan -H pg${PG_STANDBY_NODE_ID} | tee .ssh/known_hosts | |
#postgresql configs | |
USER postgres | |
WORKDIR ${PG_ETC_DIR} | |
ADD etc . | |
RUN /bin/echo "include 'replication.postgresql.conf'" >> /etc/postgresql/9.5/main/postgresql.conf | |
USER root | |
RUN rm -f /tmp/pg*_key.pub && rm -f /etc/service/sshd/down | |
CMD ["/sbin/my_init"] |
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
FROM pkalinsky/pg_base:latest | |
MAINTAINER philip.kalinsky@eloquentbits.com | |
ENV PG_VERSION=9.5 \ | |
UBUNTU_RELEASE=xenial \ | |
PG_DATA_DIR=/var/lib/postgresql/${PG_VERSION}/main \ | |
PG_HOME=/var/lib/postgresql \ | |
PG_ETC_DIR=/etc/postgresql/${PG_VERSION}/main \ | |
PG_STANDBY_NODE_ID=2 PG_MASTER_NODE_ID=1 \ | |
PG_SSH_DIR=/var/lib/postgresql/.ssh | |
# Clean up APT when done. | |
#RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
RUN mkdir -p ${PG_SSH_DIR} | |
ADD pg${PG_STANDBY_NODE_ID}_key ${PG_SSH_DIR}/id_rsa | |
ADD pg${PG_MASTER_NODE_ID}_key.pub /tmp/ | |
RUN cat /tmp/pg${PG_MASTER_NODE_ID}_key.pub >> ${PG_SSH_DIR}/authorized_keys && \ | |
chown postgres:postgres -R ${PG_SSH_DIR} | |
USER postgres | |
WORKDIR ${PG_ETC_DIR} | |
#postgresql configs | |
ADD etc . | |
RUN /bin/echo "include 'replication.postgresql.conf'" >> /etc/postgresql/9.5/main/postgresql.conf | |
#ssh-keyscan -H pg${PG_MASTER_NODE_ID} | tee .ssh/known_hosts | |
#createuser -s repmgr && createdb repmgr -O repmgr | |
#psql repmgr -c "ALTER USER 'repmgr' WITH PASSWORD 'repmgr';" | |
USER root | |
#TODO generate node id in repmgr config | |
RUN ln -s ${PG_ETC_DIR}/repmgr.conf /etc/repmgr.conf | |
RUN rm -f /tmp/pg*_key.pub && rm -f /etc/service/sshd/down | |
CMD ["/sbin/my_init"] |
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
FROM phusion/baseimage:0.9.19 | |
MAINTAINER philip.kalinsky@eloquentbits.com | |
# Set locale | |
RUN localedef -c -i en_US -f UTF-8 en_US.UTF-8 | |
ENV LANG="en_US.UTF-8" LANGUAGE="en_US:en" LC_ALL="en_US.UTF-8" | |
ENV PG_VERSION=9.5 \ | |
UBUNTU_RELEASE=xenial \ | |
PG_DATA_DIR=/var/lib/postgresql/${PG_VERSION}/main \ | |
PG_ETC_DIR=/etc/postgresql/${PG_VERSION}/main | |
RUN apt-get update && apt-get upgrade -y -o Dpkg::Options::="--force-confold" | |
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 | |
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ ${UBUNTU_RELEASE}-pgdg main" > /etc/apt/sources.list.d/pgdg.list | |
RUN apt-get update && \ | |
apt-get install -y \ | |
iputils-ping wget \ | |
python-software-properties \ | |
software-properties-common \ | |
postgresql-common \ | |
postgresql-${PG_VERSION} \ | |
postgresql-client-${PG_VERSION} \ | |
postgresql-contrib-${PG_VERSION} \ | |
postgresql-${PG_VERSION}-repmgr \ | |
repmgr && \ | |
wget -O /usr/local/bin/ep https://github.com/kreuzwerker/envplate/releases/download/v0.0.8/ep-linux && chmod +x /usr/local/bin/ep | |
# Clean up APT when done. | |
#RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
ADD etc/sv/postgresql/ /etc/sv/postgresql/ | |
RUN ln -s /etc/sv/postgresql /etc/service/postgresql && \ | |
chmod +x /etc/sv/postgresql/run /etc/sv/postgresql/log/run && \ | |
mkdir -p /var/run/postgresql/${PG_VERSION}-main.pg_stat_tmp && \ | |
chown postgres /var/run/postgresql/${PG_VERSION}-main.pg_stat_tmp | |
# Use baseimage-docker's init system. | |
CMD ["/sbin/my_init"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment