diff --git a/Dockerfile b/Dockerfile index 64baca2..8cd2fbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,32 @@ -FROM ubuntu:xenial +FROM ubuntu:22.04 LABEL maintainer="lucas@vieira.io" -LABEL version="1.0" +LABEL version="1.1" + +ENV DEBIAN_FRONTEND=noninteractive RUN apt-get -y update \ && apt-get -y upgrade -RUN apt-get -y install postgresql-9.5 bucardo jq +RUN apt-get -y install postgresql-14 jq wget curl perl make build-essential bucardo + +ARG BUCARDO_VERSION=5.6.0 -COPY etc/pg_hba.conf /etc/postgresql/9.5/main/ +WORKDIR /tmp +RUN wget -O /tmp/bucardo.tgz http://bucardo.org/downloads/Bucardo-${BUCARDO_VERSION}.tar.gz && \ + tar zxf /tmp/bucardo.tgz && \ + cd Bucardo-${BUCARDO_VERSION} && \ + INSTALL_BUCARDODIR=/usr/bin perl Makefile.PL && \ + make -j && \ + make install && \ + rm -rf /tmp/Bucardo-${BUCARDO_VERSION} + +COPY etc/pg_hba.conf /etc/postgresql/14/main/ COPY etc/bucardorc /etc/bucardorc -RUN chown postgres /etc/postgresql/9.5/main/pg_hba.conf -RUN chown postgres /etc/bucardorc -RUN chown postgres /var/log/bucardo -RUN mkdir /var/run/bucardo && chown postgres /var/run/bucardo -RUN usermod -aG bucardo postgres +RUN mkdir /var/run/bucardo +RUN chown postgres /etc/postgresql/14/main/pg_hba.conf /etc/bucardorc /var/log/bucardo /var/run/bucardo +RUN usermod -aG postgres bucardo RUN service postgresql start \ && su - postgres -c "bucardo install --batch" @@ -24,4 +35,6 @@ COPY lib/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh VOLUME "/media/bucardo" +WORKDIR /media/bucardo + CMD ["/bin/bash","-c","/entrypoint.sh"] diff --git a/etc/bucardorc b/etc/bucardorc index 1829168..8ea57df 100644 --- a/etc/bucardorc +++ b/etc/bucardorc @@ -1,3 +1,3 @@ dbport = 5432 -dbuser = bucardo +dbuser = postgres dbname = bucardo diff --git a/etc/pg_hba.conf b/etc/pg_hba.conf index d3e4e9d..55615bd 100644 --- a/etc/pg_hba.conf +++ b/etc/pg_hba.conf @@ -1,5 +1,5 @@ -local all postgres peer -local bucardo bucardo md5 +local all postgres trust +local bucardo bucardo trust local all all peer -host all all 127.0.0.1/32 md5 +host all all 127.0.0.1/32 trust host all all ::1/128 md5 diff --git a/lib/entrypoint.sh b/lib/entrypoint.sh index deab014..095e36e 100644 --- a/lib/entrypoint.sh +++ b/lib/entrypoint.sh @@ -120,11 +120,11 @@ add_databases_to_bucardo() { db_id=$(db_attr $db_index id integer) db_pass=$(load_db_pass $db_index) run_bucardo_command "del db db$db_id --force" - run_bucardo_command "add db db$db_id dbname=\"$(db_attr $db_index dbname string)\" \ + run_bucardo_command "add db db$db_id --force dbname=\"$(db_attr $db_index dbname string)\" \ user=\"$(db_attr $db_index user string)\" \ pass=\"$db_pass\" \ - host=\"$(db_attr $db_index host string)\"" - db_index=$(expr $db_index + 1) + host=\"$(db_attr $db_index host string)\"" || exit 2 + db_index=$(expr $db_index + 1) done } @@ -161,7 +161,7 @@ add_syncs_to_bucardo() { run_bucardo_command "add sync sync$sync_index \ dbs=$DB_STRING \ tables=$(sync_attr $sync_index tables list) \ - onetimecopy=$one_time_copy" + onetimecopy=$one_time_copy" || exit 2 sync_index=$(expr $sync_index + 1) done }