FROM alpine:3.7
LABEL mantainer="robert.gauto@gmail.com"

ENV CONFIG_PATH=/etc PID_PATH=/var/run/pgpool

RUN set -x \
	apk update && \
	apk upgrade && \
	apk add --no-cache --virtual \
	pgpool && \
	mkdir -p $PID_PATH && \
	mkdir -p $CONFIG_PATH

VOLUME ["$CONFIG_PATH"]

COPY pcp.conf "$CONFIG_PATH"
COPY pool_hba.conf "$CONFIG_PATH"
COPY pgpool.conf "$CONFIG_PATH"

COPY failover.sh "$CONFIG_PATH"
COPY recovery_1st_stage "$CONFIG_PATH"
COPY pgpool_remote_start "$CONFIG_PATH"

RUN chmod +x /etc/failover.sh && chmod +x /etc/recovery_1st_stage && chmod +x /etc/pgpool_remote_start

ADD entrypoint.sh ./

#EXPOSE 9999

ENTRYPOINT ["./entrypoint.sh"]
CMD ["pgpool"]
