FROM postgres:9.6.1

ENV STKEEPER_CLUSTER_NAME=stolon-cluster \
    STKEEPER_STORE_BACKEND=etcdv3 \
    STKEEPER_STORE_ENDPOINTS=http://localhost:2379 \
    STKEEPER_DATA_DIR=/data/postgres

RUN mkdir -p ${STKEEPER_DATA_DIR} && \
    chmod 700 ${STKEEPER_DATA_DIR} && \
    chown postgres -R ${STKEEPER_DATA_DIR}
VOLUME ["${STKEEPER_DATA_DIR}"]

COPY etc/keeper-entrypoint.sh /usr/local/bin/
COPY bin/stolon-keeper bin/stolonctl /usr/local/bin/

USER postgres
ENTRYPOINT ["keeper-entrypoint.sh"]
