diff --git a/.github/workflows/submit.yml b/.github/workflows/submit.yml index d5fd9de..3986676 100644 --- a/.github/workflows/submit.yml +++ b/.github/workflows/submit.yml @@ -4,7 +4,7 @@ on: branches: - main env: - VERSION: "0.2.3" + VERSION: "0.2.4" IMAGE_NAME: "lanterndata/lantern-suite" jobs: docker: diff --git a/Dockerfile b/Dockerfile index f658bff..532ad6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,17 @@ ARG TARGETARCH ARG PG_CRON_VERSION="7e91e72b1bebc5869bb900d9253cc9e92518b33f" ENV OS_ARCH="${TARGETARCH:-amd64}" -RUN apt update && apt install -y curl wget make jq pgbouncer procps bc git-all gcc postgresql-server-dev-${PG_VERSION} +RUN apt update && apt install -y autoconf automake libtool pandoc libevent-dev pkg-config curl wget make jq procps bc git-all gcc postgresql-server-dev-${PG_VERSION} + +# Install pgbouncer +RUN git clone https://github.com/var77/pgbouncer.git /tmp/pgbouncer && \ + cd /tmp/pgbouncer && \ + git submodule init && git submodule update && \ + ./autogen.sh && \ + ./configure --prefix=/usr/local && \ + make -j && \ + make install && \ + rm -rf /tmp/pgbouncer # Install pg_cron RUN git clone https://github.com/citusdata/pg_cron.git /tmp/pg_cron && \ @@ -23,7 +33,7 @@ RUN git clone --branch v0.7.3-lanterncloud https://github.com/lanterndata/pgvect make OPTFLAGS="" -j && \ make install - # Install Lantern +# Install Lantern RUN cd /tmp && \ wget https://github.com/lanterndata/lantern/releases/download/v${LANTERN_VERSION}/lantern-${LANTERN_VERSION}.tar -O lantern.tar && \ tar xf lantern.tar && \ diff --git a/scripts/configure-pgbouncer.sh b/scripts/configure-pgbouncer.sh index b0be59d..a80ac5a 100755 --- a/scripts/configure-pgbouncer.sh +++ b/scripts/configure-pgbouncer.sh @@ -11,6 +11,24 @@ cd $PG_SOCKET_DIR check_cmd="pg_isready" ready_counter=$POSTGRESQL_INIT_MAX_TIMEOUT +######################## +# Check if the provided argument is a boolean or is the string 'yes/true' +# Arguments: +# $1 - Value to check +# Returns: +# Boolean +######################### +is_boolean_yes() { + local -r bool="${1:-}" + # comparison is performed without regard to the case of alphabetic characters + shopt -s nocasematch + if [[ "$bool" = 1 || "$bool" =~ ^(yes|true)$ ]]; then + true + else + false + fi +} + generate_random_string() { local count="32" local filter @@ -52,6 +70,18 @@ SQL psql -Atq -U postgres -d postgres -c "SELECT concat('\"', usename, '\" \"', passwd, '\"') FROM pg_shadow WHERE usename='_pgbouncer'" > userlist.txt +auth_query='SELECT usename, passwd FROM pg_shadow WHERE usename=$1' + +if is_boolean_yes "${LANTERN_MULTI_TENANT:-no}"; then + psql -U postgres -h $PG_SOCKET_DIR -p $POSTGRESQL_PORT_NUMBER postgres -t < pgbouncer.ini [pgbouncer] # Connection settings @@ -62,7 +92,7 @@ auth_user = _pgbouncer auth_hba_file = $POSTGRESQL_PGHBA_FILE auth_file = userlist.txt unix_socket_dir = $PG_SOCKET_DIR -auth_query = SELECT usename, passwd FROM pg_shadow WHERE usename=\$1 +auth_query = $auth_query auth_dbname = postgres pidfile = pgbouncer.pid