Skip to content

Commit b752996

Browse files
Merge pull request #12 from jayanth-kumar-morem/main
2 parents e612601 + a2cfc9b commit b752996

4 files changed

Lines changed: 74 additions & 6 deletions

File tree

.github/workflows/smoke-test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ jobs:
5252
fi
5353
if psql -c "select 1"
5454
then
55+
echo "Test Citus Extension"
56+
psql -c "CREATE EXTENSION citus;"
57+
psql -c "SELECT * FROM citus_version();"
58+
59+
echo "Test Citus Distributed Table"
60+
psql -c "CREATE TABLE test_distributed_table (id serial primary key, data text);"
61+
psql -c "SELECT create_distributed_table('test_distributed_table', 'id');"
62+
psql -c "INSERT INTO test_distributed_table (data) VALUES ('test data');"
63+
psql -c "SELECT * FROM test_distributed_table;"
64+
5565
break
5666
fi
5767
sleep 1

Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ RUN set -ex \
7373
&& rm -rf /build \
7474
&& sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" /usr/local/share/postgresql/postgresql.conf.sample
7575

76+
# Add Citus to shared_preload_libraries
77+
RUN echo "shared_preload_libraries = 'citus,timescaledb'" >> /usr/local/share/postgresql/postgresql.conf.sample
78+
7679
# Adding PG Vector
7780

7881
RUN cd /tmp
@@ -93,3 +96,38 @@ RUN apk add --no-cache --virtual .build-deps \
9396
&& ls \
9497
&& make \
9598
&& make install
99+
100+
## Adding Citus
101+
102+
# Install Citus dependencies
103+
RUN apk add --no-cache --virtual .citus-deps \
104+
curl \
105+
jq
106+
107+
# Install Citus
108+
ARG CITUS_VERSION="11.2.0"
109+
RUN set -ex \
110+
&& apk add --no-cache --virtual .citus-build-deps \
111+
gcc \
112+
libc-dev \
113+
make \
114+
curl-dev \
115+
lz4-dev \
116+
zstd-dev \
117+
clang \
118+
krb5-dev \
119+
icu-dev \
120+
libxslt-dev \
121+
libxml2-dev \
122+
llvm15-dev \
123+
&& CITUS_DOWNLOAD_URL="https://github.com/citusdata/citus/archive/refs/tags/v${CITUS_VERSION}.tar.gz" \
124+
&& curl -L -o /tmp/citus.tar.gz "${CITUS_DOWNLOAD_URL}" \
125+
&& tar -C /tmp -xvf /tmp/citus.tar.gz \
126+
&& chown -R postgres:postgres /tmp/citus-${CITUS_VERSION} \
127+
&& cd /tmp/citus-${CITUS_VERSION} \
128+
&& PATH="/usr/local/pgsql/bin:$PATH" ./configure \
129+
&& make \
130+
&& make install \
131+
&& cd ~ \
132+
&& rm -rf /tmp/citus.tar.gz /tmp/citus-${CITUS_VERSION} \
133+
&& apk del .citus-deps .citus-build-deps

bitnami/Dockerfile

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ RUN set +o pipefail \
5151
ARG PG_VERSION
5252
FROM bitnami/postgresql:${PG_VERSION}
5353
ARG PG_VERSION
54+
ARG CITUS_VERSION="11.2.0"
5455

5556
LABEL maintainer="Timescale https://www.timescale.com"
5657

@@ -89,6 +90,22 @@ RUN set -ex \
8990
&& cd build && make install \
9091
&& cd ~ \
9192
\
93+
# Install Citus
94+
&& apt-get update \
95+
&& apt-get install -y curl liblz4-dev libzstd-dev clang libkrb5-dev libicu-dev libxslt1-dev libxml2-dev llvm-dev libcurl4-openssl-dev \
96+
&& CITUS_DOWNLOAD_URL="https://github.com/citusdata/citus/archive/refs/tags/v${CITUS_VERSION}.tar.gz" \
97+
&& curl -L -o /tmp/citus.tar.gz "${CITUS_DOWNLOAD_URL}" \
98+
&& tar -C /tmp -xvf /tmp/citus.tar.gz \
99+
&& addgroup --system postgres \
100+
&& adduser --system --ingroup postgres --home /opt/bitnami/postgresql --no-create-home postgres \
101+
&& chown -R postgres:postgres /tmp/citus-${CITUS_VERSION} \
102+
&& cd /tmp/citus-${CITUS_VERSION} \
103+
&& PATH="/opt/bitnami/postgresql/bin:$PATH" ./configure \
104+
&& make \
105+
&& make install \
106+
&& cd ~ \
107+
&& rm -rf /tmp/citus.tar.gz /tmp/citus-${CITUS_VERSION} \
108+
\
92109
&& apt-get autoremove --purge -y \
93110
\
94111
build-essential \
@@ -105,8 +122,11 @@ RUN set -ex \
105122
"${HOME}/.cache" \
106123
/var/lib/apt/lists/* \
107124
/tmp/* \
108-
/var/tmp/*
109-
125+
/var/tmp/* \
126+
\
127+
# Update shared_preload_libraries
128+
&& sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'citus,timescaledb'/g" /opt/bitnami/postgresql/conf/postgresql.conf
129+
110130
USER 1001
111131

112132
ENTRYPOINT [ "/opt/bitnami/scripts/postgresql/timescaledb-bitnami-entrypoint.sh" ]

bitnami/timescaledb-bitnami-entrypoint.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/env bash
22

3-
# We have to use the bitnami configuration variable to add timescaledb to
4-
# shared preload list, or else it gets overwritten.
3+
# We have to use the Bitnami configuration variable to add TimescaleDB and Citus to
4+
# the shared preload list, or else it gets overwritten.
55
if [ -z "$POSTGRESQL_SHARED_PRELOAD_LIBRARIES" ]
66
then
7-
POSTGRESQL_SHARED_PRELOAD_LIBRARIES=timescaledb
7+
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="citus,timescaledb"
88
else
9-
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="$POSTGRESQL_SHARED_PRELOAD_LIBRARIES,timescaledb"
9+
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="citus,timescaledb,$POSTGRESQL_SHARED_PRELOAD_LIBRARIES"
1010
fi
1111
export POSTGRESQL_SHARED_PRELOAD_LIBRARIES
1212

0 commit comments

Comments
 (0)