FROM robinthoni/postgres-backup-multiarch:9.6

ARG CONFIG_DIR=/etc/default/config-files/

RUN rm -rf /var/log/*

COPY ./vars-vars /etc/vars-vars

COPY ./vars-files /etc/vars-files

COPY ./common.sh /common.sh

COPY ./run.sh /run.sh

RUN mv -v /usr/share/postgresql/$PG_MAJOR/pg_hba.conf.sample /usr/share/postgresql/ \
        && ln -sv ../pg_hba.conf.sample /usr/share/postgresql/$PG_MAJOR/

RUN mkdir "${CONFIG_DIR}"

COPY ./config/postgresql.conf "${CONFIG_DIR}"/postgresql.conf

COPY ./config/pg_hba.conf "${CONFIG_DIR}"/pg_hba.conf

COPY ./config/replication.sql "${CONFIG_DIR}"/replication.sql

COPY ./config/readonly_user.sql "${CONFIG_DIR}"/readonly_user.sql

COPY ./docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d