Merge pull request #219 from zalando/bugfix/docker_fixe

Bugfix/docker fixe
This commit is contained in:
Alexander Kukushkin
2016-06-17 11:06:01 +02:00
committed by GitHub
3 changed files with 43 additions and 69 deletions
+1
View File
@@ -9,3 +9,4 @@ build/
coverage.xml
junit.xml
pgpass
scm-source.json
+20 -23
View File
@@ -1,39 +1,36 @@
## This Dockerfile is meant to aid in the building and debugging patroni whilst developing on your local machine
## It has all the necessary components to play/debug with a single node appliance, running etcd
FROM ubuntu:14.04
FROM ubuntu:16.04
MAINTAINER Feike Steenbergen <[email protected]>
# We need curl
RUN apt-get update -y && apt-get install curl -y
# Add PGDG repositories
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt-get update -y
RUN apt-get upgrade -y
RUN echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/01norecommend
RUN echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/01norecommend
ENV PGVERSION 9.5
RUN apt-get install postgresql-${PGVERSION} postgresql-server-dev-${PGVERSION} -y
RUN apt-get install python python-dev python-pip -y
ADD requirements-py2.txt /requirements-py2.txt
RUN pip install -r /requirements-py2.txt
RUN apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install -y curl postgresql-${PGVERSION} python-psycopg2 python-yaml python-requests python-six python-click \
python-dateutil python-tzlocal python-urllib3 python-dnspython python-pip python-setuptools python-kazoo python \
&& pip install python-etcd==0.4.3 python-consul \
&& apt-get remove -y python-pip python-setuptools \
&& apt-get autoremove -y \
# Clean up
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
ENV PATH /usr/lib/postgresql/${PGVERSION}/bin:$PATH
ADD patroni.py /patroni.py
ADD patronictl.py /patronictl.py
ADD patroni/ /patroni
ADD patronictl.py patroni.py docker/entrypoint.sh /
ADD patroni /patroni/
RUN ln -s /patroni/patroni.py /usr/local/bin/patroni \
&& ln -s /patroni/patronictl.py /usr/local/bin/patronictl
RUN ln -s /patroni.py /usr/local/bin/patroni
RUN ln -s /patronictl.py /usr/local/bin/patronictl
ENV ETCDVERSION 2.2.5
ENV ETCDVERSION 2.3.6
RUN curl -L https://github.com/coreos/etcd/releases/download/v${ETCDVERSION}/etcd-v${ETCDVERSION}-linux-amd64.tar.gz | tar xz -C /bin --strip=1 --wildcards --no-anchored etcd etcdctl
### Setting up a simple script that will serve as an entrypoint
RUN mkdir /data/ && touch /var/log/etcd.log /var/log/etcd.err /pgpass /patroni/postgres.yml
RUN chown postgres:postgres -R /patroni/ /data/ /pgpass /var/log/etcd.* /patroni/postgres.yml
ADD docker/entrypoint.sh /entrypoint.sh
RUN mkdir /data/ && touch /var/log/etcd.log /var/log/etcd.err /pgpass /patroni/postgres.yml \
&& chown postgres:postgres -R /patroni/ /data/ /pgpass /var/log/etcd.* /patroni/postgres.yml
EXPOSE 4001 5432 2380
+22 -46
View File
@@ -70,6 +70,7 @@ while getopts "$optspec" optchar; do
esac
done
## We start an etcd
if [ -z ${ETCD_CLUSTER} ]
then
etcd --data-dir /tmp/etcd.data \
@@ -79,60 +80,35 @@ then
ETCD_CLUSTER="127.0.0.1:4001"
fi
mkdir -p ~postgres/.config/patroni
cat > ~postgres/.config/patroni/patronictl.yaml <<__EOF__
{dcs_api: 'etcd://${ETCD_CLUSTER}', namespace: /service/}
__EOF__
export PATRONI_SCOPE
export PATRONI_NAME="${HOSTNAME}"
export PATRONI_ETCD_HOST="$ETCD_CLUSTER"
export PATRONI_RESTAPI_CONNECT_ADDRESS="${DOCKER_IP}:8008"
export PATRONI_RESTAPI_LISTEN="0.0.0.0:8008"
export PATRONI_admin_PASSWORD="admin"
export PATRONI_admin_OPTIONS="createdb, createrole"
export PATRONI_POSTGRESQL_CONNECT_ADDRESS="${DOCKER_IP}:5432"
export PATRONI_POSTGRESQL_LISTEN="0.0.0.0:5432"
export PATRONI_POSTGRESQL_DATA_DIR="data/${PATRONI_SCOPE}"
export PATRONI_REPLICATION_USERNAME="replicator"
export PATRONI_REPLICATION_PASSWORD="abcd"
export PATRONI_SUPERUSER_USERNAME="postgres"
export PATRONI_SUPERUSER_PASSWORD="postgres"
export PATRONI_POSTGRESQL_PGPASS="$HOME/.pgpass"
cat > /patroni/postgres.yaml <<__EOF__
bootstrap:
dcs:
postgresql:
use_pg_rewind: true
ttl: &ttl 30
loop_wait: &loop_wait 10
scope: &scope '${PATRONI_SCOPE}'
namespace: 'patroni'
restapi:
listen: 0.0.0.0:8008
connect_address: ${DOCKER_IP}:8008
etcd:
scope: *scope
ttl: *ttl
host: ${ETCD_CLUSTER}
postgresql:
name: ${HOSTNAME}
scope: *scope
listen: 0.0.0.0:5432
connect_address: ${DOCKER_IP}:5432
data_dir: data/postgresql0
maximum_lag_on_failover: 1048576 # 1 megabyte in bytes
pg_hba:
- host all all 0.0.0.0/0 md5
- hostssl all all 0.0.0.0/0 md5
- host replication replicator ${DOCKER_IP}/16 md5
replication:
username: replicator
password: rep-pass
network: 127.0.0.1/32
superuser:
password: zalando
restore: patroni/scripts/restore.py
admin:
username: admin
password: admin
parameters:
archive_mode: "on"
wal_level: hot_standby
archive_command: 'true'
max_wal_senders: 20
listen_addresses: 0.0.0.0
max_wal_size: 1GB
min_wal_size: 128MB
wal_keep_segments: 64
archive_timeout: 1800s
max_replication_slots: 20
hot_standby: "on"
__EOF__
cat /patroni/postgres.yaml
mkdir -p "$HOME/.config/patroni"
ln -s /patroni/postgres.yaml "$HOME/.config/patroni/patronictl.yaml"
if [ ! -z $CHEAT ]
then