Skip to content

Commit 739e4b6

Browse files
add citus extension (#129)
Signed-off-by: Piyush Raj <[email protected]> Co-authored-by: Karun Agarwal <[email protected]>
1 parent 7fd3328 commit 739e4b6

File tree

7 files changed

+90
-8
lines changed

7 files changed

+90
-8
lines changed

.github/workflows/smoke-test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ jobs:
6565
psql -c "INSERT INTO test_geometry_table (geom) VALUES (ST_GeomFromText('POINT(0 0)', 4326));"
6666
psql -c "SELECT * FROM test_geometry_table;"
6767
68+
echo "Test Citus Extension"
69+
psql -c "CREATE EXTENSION citus;"
70+
psql -c "SELECT * FROM citus_version();"
71+
72+
echo "Test Citus Distributed Table"
73+
psql -c "CREATE TABLE test_distributed_table (id serial primary key, data text);"
74+
psql -c "SELECT create_distributed_table('test_distributed_table', 'id');"
75+
psql -c "INSERT INTO test_distributed_table (data) VALUES ('test data');"
76+
psql -c "SELECT * FROM test_distributed_table;"
77+
6878
break
6979
fi
7080
sleep 1

Dockerfile

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ RUN set -ex \
7575

7676

7777
# Update to shared_preload_libraries
78-
RUN echo "shared_preload_libraries = 'timescaledb,pg_cron'" >> /usr/local/share/postgresql/postgresql.conf.sample
78+
RUN echo "shared_preload_libraries = 'timescaledb,pg_cron,citus'" >> /usr/local/share/postgresql/postgresql.conf.sample
7979
# Adding PG Vector
8080

8181
RUN cd /tmp
@@ -200,4 +200,39 @@ RUN set -eux \
200200
# clean
201201
&& cd / \
202202
&& rm -rf /usr/src/postgis \
203-
&& apk del .fetch-deps .build-deps
203+
&& apk del .fetch-deps .build-deps
204+
205+
## Adding Citus
206+
207+
ARG CITUS_VERSION
208+
# Install Citus dependencies
209+
RUN set -ex \
210+
&& apk add --no-cache --virtual .citus-deps \
211+
curl \
212+
jq \
213+
# Install Citus
214+
&& apk add --no-cache --virtual .citus-build-deps \
215+
gcc \
216+
libc-dev \
217+
make \
218+
curl-dev \
219+
lz4-dev \
220+
zstd-dev \
221+
clang-15 \
222+
krb5-dev \
223+
icu-dev \
224+
libxslt-dev \
225+
libxml2-dev \
226+
llvm15-dev \
227+
&& CITUS_DOWNLOAD_URL="https://github.com/citusdata/citus/archive/refs/tags/v${CITUS_VERSION}.tar.gz" \
228+
&& curl -L -o /tmp/citus.tar.gz "${CITUS_DOWNLOAD_URL}" \
229+
&& tar -C /tmp -xvf /tmp/citus.tar.gz \
230+
&& chown -R postgres:postgres /tmp/citus-${CITUS_VERSION} \
231+
&& cd /tmp/citus-${CITUS_VERSION} \
232+
&& PATH="/usr/local/pgsql/bin:$PATH" ./configure \
233+
&& make \
234+
&& make install \
235+
&& cd ~ \
236+
&& rm -rf /tmp/citus.tar.gz /tmp/citus-${CITUS_VERSION} \
237+
&& apk del .citus-deps .citus-build-deps
238+

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-)
77
TS_VERSION=2.13.0
88
PG_CRON_VERSION=v1.6.0
99
POSTGIS_VERSION=3.4.1
10+
CITUS_VERSION=12.1.0
1011
PREV_TS_VERSION=$(shell wget --quiet -O - https://raw.githubusercontent.com/timescale/timescaledb/${TS_VERSION}/version.config | grep update_from_version | sed -e 's!update_from_version = !!')
1112
PREV_TS_IMAGE="timescale/timescaledb:$(PREV_TS_VERSION)-pg$(PG_VER_NUMBER)$(PREV_EXTRA)"
1213
PREV_IMAGE=$(shell if docker pull $(PREV_TS_IMAGE) >/dev/null; then echo "$(PREV_TS_IMAGE)"; else echo "postgres:$(PG_VER_NUMBER)-alpine"; fi )
@@ -30,7 +31,8 @@ DOCKER_BUILD_ARGS = --build-arg TS_VERSION=$(TS_VERSION) \
3031
--build-arg PG_VERSION=$(PG_VER_NUMBER) \
3132
--build-arg PREV_IMAGE=$(PREV_IMAGE) \
3233
--build-arg PG_CRON_VERSION=$(PG_CRON_VERSION) \
33-
--build-arg POSTGIS_VERSION=$(POSTGIS_VERSION)
34+
--build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) \
35+
--build-arg CITUS_VERSION=$(CITUS_VERSION)
3436

3537

3638
default: image

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
## Test on GitPod
22
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/ChakshuGautam/postgres-tsdb-vector-docker)
33

4-
## Postgres
4+
## Current and future supported extensions
55

66
- [x] [PgVector](https://github.com/pgvector/pgvector)
77
- [x] [TimescaleDB](https://github.com/timescale/timescaledb)
88
- [x] [PgCron ](https://github.com/citusdata/pg_cron)
99
- [x] [PostGIS](https://postgis.net)
10-
- [ ] [Citus](https://www.citusdata.com/)
10+
- [x] [Citus](https://www.citusdata.com/)
1111

1212
## Releases
1313
- [Versioning Policy](./docs/version-policy.md)

bitnami/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,39 @@ RUN set -eux \
208208
/tmp/* \
209209
/var/tmp/*
210210

211+
# add Citus
212+
ARG CITUS_VERSION
213+
RUN set -eux \
214+
&& apt-get update \
215+
&& apt-get install -y libc-dev make libssl-dev curl gcc liblz4-dev libzstd-dev clang libkrb5-dev libicu-dev libxslt1-dev libxml2-dev llvm-dev libcurl4-openssl-dev \
216+
&& CITUS_DOWNLOAD_URL="https://github.com/citusdata/citus/archive/refs/tags/v${CITUS_VERSION}.tar.gz" \
217+
&& curl -L -o /tmp/citus.tar.gz "${CITUS_DOWNLOAD_URL}" \
218+
&& tar -C /tmp -xvf /tmp/citus.tar.gz \
219+
&& addgroup --system postgres \
220+
&& adduser --system --ingroup postgres --home /opt/bitnami/postgresql --no-create-home postgres \
221+
&& chown -R postgres:postgres /tmp/citus-${CITUS_VERSION} \
222+
&& cd /tmp/citus-${CITUS_VERSION} \
223+
&& PATH="/opt/bitnami/postgresql/bin:$PATH" ./configure \
224+
&& make \
225+
&& make install \
226+
&& cd ~ \
227+
&& rm -rf /tmp/citus.tar.gz /tmp/citus-${CITUS_VERSION} \
228+
\
229+
&& apt-get autoremove --purge -y \
230+
\
231+
build-essential \
232+
libssl-dev \
233+
gcc \
234+
libc-dev \
235+
make \
236+
&& apt-get clean -y \
237+
&& rm -rf \
238+
/build \
239+
"${HOME}/.cache" \
240+
/var/lib/apt/lists/* \
241+
/tmp/* \
242+
/var/tmp/*
243+
211244
USER 1001
212245

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

bitnami/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-)
77
PG_CRON_VERSION=v1.6.0
88
TS_VERSION=2.13.0
99
POSTGIS_VERSION=3.4.1
10+
CITUS_VERSION=12.1.0
1011
PREV_TS_VERSION=$(shell wget --quiet -O - https://raw.githubusercontent.com/timescale/timescaledb/${TS_VERSION}/version.config | grep update_from_version | sed -e 's!update_from_version = !!')
1112
PREV_TS_IMAGE="timescale/timescaledb:$(PREV_TS_VERSION)-pg$(PG_VER_NUMBER)-bitnami"
1213
PREV_IMAGE=$(shell if docker pull $(PREV_TS_IMAGE) >/dev/null; then echo "$(PREV_TS_IMAGE)"; else echo "bitnami/postgresql:$(PG_VER_NUMBER)"; fi )
@@ -27,7 +28,8 @@ DOCKER_BUILD_ARGS = --build-arg PG_VERSION=$(PG_VER_NUMBER) \
2728
--build-arg TS_VERSION=$(TS_VERSION) \
2829
--build-arg PREV_IMAGE=$(PREV_IMAGE) \
2930
--build-arg PG_CRON_VERSION=$(PG_CRON_VERSION) \
30-
--build-arg POSTGIS_VERSION=$(POSTGIS_VERSION)
31+
--build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) \
32+
--build-arg CITUS_VERSION=$(CITUS_VERSION)
3133

3234

3335
default: image

bitnami/timescaledb-bitnami-entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# shared preload list, or else it gets overwritten.
55
if [ -z "$POSTGRESQL_SHARED_PRELOAD_LIBRARIES" ]
66
then
7-
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="timescaledb,pg_cron"
7+
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="timescaledb,pg_cron,citus"
88
else
9-
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="$POSTGRESQL_SHARED_PRELOAD_LIBRARIES,timescaledb,pg_cron"
9+
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="$POSTGRESQL_SHARED_PRELOAD_LIBRARIES,timescaledb,pg_cron,citus"
1010
fi
1111
export POSTGRESQL_SHARED_PRELOAD_LIBRARIES
1212

0 commit comments

Comments
 (0)