diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index bb2e6b19..41a58fa5 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -65,6 +65,16 @@ jobs: psql -c "INSERT INTO test_geometry_table (geom) VALUES (ST_GeomFromText('POINT(0 0)', 4326));" psql -c "SELECT * FROM test_geometry_table;" + echo "Test Citus Extension" + psql -c "CREATE EXTENSION citus;" + psql -c "SELECT * FROM citus_version();" + + echo "Test Citus Distributed Table" + psql -c "CREATE TABLE test_distributed_table (id serial primary key, data text);" + psql -c "SELECT create_distributed_table('test_distributed_table', 'id');" + psql -c "INSERT INTO test_distributed_table (data) VALUES ('test data');" + psql -c "SELECT * FROM test_distributed_table;" + break fi sleep 1 diff --git a/Dockerfile b/Dockerfile index 0d37a6ca..0bb9a549 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,7 +75,7 @@ RUN set -ex \ # Update to shared_preload_libraries -RUN echo "shared_preload_libraries = 'timescaledb,pg_cron'" >> /usr/local/share/postgresql/postgresql.conf.sample +RUN echo "shared_preload_libraries = 'timescaledb,pg_cron,citus'" >> /usr/local/share/postgresql/postgresql.conf.sample # Adding PG Vector RUN cd /tmp @@ -200,4 +200,39 @@ RUN set -eux \ # clean && cd / \ && rm -rf /usr/src/postgis \ - && apk del .fetch-deps .build-deps \ No newline at end of file + && apk del .fetch-deps .build-deps + +## Adding Citus + +ARG CITUS_VERSION +# Install Citus dependencies +RUN set -ex \ + && apk add --no-cache --virtual .citus-deps \ + curl \ + jq \ +# Install Citus + && apk add --no-cache --virtual .citus-build-deps \ + gcc \ + libc-dev \ + make \ + curl-dev \ + lz4-dev \ + zstd-dev \ + clang-15 \ + krb5-dev \ + icu-dev \ + libxslt-dev \ + libxml2-dev \ + llvm15-dev \ + && CITUS_DOWNLOAD_URL="https://github.com/citusdata/citus/archive/refs/tags/v${CITUS_VERSION}.tar.gz" \ + && curl -L -o /tmp/citus.tar.gz "${CITUS_DOWNLOAD_URL}" \ + && tar -C /tmp -xvf /tmp/citus.tar.gz \ + && chown -R postgres:postgres /tmp/citus-${CITUS_VERSION} \ + && cd /tmp/citus-${CITUS_VERSION} \ + && PATH="/usr/local/pgsql/bin:$PATH" ./configure \ + && make \ + && make install \ + && cd ~ \ + && rm -rf /tmp/citus.tar.gz /tmp/citus-${CITUS_VERSION} \ + && apk del .citus-deps .citus-build-deps + diff --git a/Makefile b/Makefile index 67fbd6d2..54be3b7d 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-) TS_VERSION=2.13.0 PG_CRON_VERSION=v1.6.0 POSTGIS_VERSION=3.4.1 +CITUS_VERSION=12.1.0 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 = !!') PREV_TS_IMAGE="timescale/timescaledb:$(PREV_TS_VERSION)-pg$(PG_VER_NUMBER)$(PREV_EXTRA)" 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) \ --build-arg PG_VERSION=$(PG_VER_NUMBER) \ --build-arg PREV_IMAGE=$(PREV_IMAGE) \ --build-arg PG_CRON_VERSION=$(PG_CRON_VERSION) \ - --build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) + --build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) \ + --build-arg CITUS_VERSION=$(CITUS_VERSION) default: image diff --git a/README.md b/README.md index ccebfbae..4ab001c2 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ ## Test on GitPod [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/ChakshuGautam/postgres-tsdb-vector-docker) -## Postgres +## Current and future supported extensions - [x] [PgVector](https://github.com/pgvector/pgvector) - [x] [TimescaleDB](https://github.com/timescale/timescaledb) - [x] [PgCron ](https://github.com/citusdata/pg_cron) - [x] [PostGIS](https://postgis.net) -- [ ] [Citus](https://www.citusdata.com/) +- [x] [Citus](https://www.citusdata.com/) ## Releases - [Versioning Policy](./docs/version-policy.md) diff --git a/bitnami/Dockerfile b/bitnami/Dockerfile index 873fa036..8d90bd41 100644 --- a/bitnami/Dockerfile +++ b/bitnami/Dockerfile @@ -208,6 +208,39 @@ RUN set -eux \ /tmp/* \ /var/tmp/* +# add Citus +ARG CITUS_VERSION +RUN set -eux \ + && apt-get update \ + && 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 \ + && CITUS_DOWNLOAD_URL="https://github.com/citusdata/citus/archive/refs/tags/v${CITUS_VERSION}.tar.gz" \ + && curl -L -o /tmp/citus.tar.gz "${CITUS_DOWNLOAD_URL}" \ + && tar -C /tmp -xvf /tmp/citus.tar.gz \ + && addgroup --system postgres \ + && adduser --system --ingroup postgres --home /opt/bitnami/postgresql --no-create-home postgres \ + && chown -R postgres:postgres /tmp/citus-${CITUS_VERSION} \ + && cd /tmp/citus-${CITUS_VERSION} \ + && PATH="/opt/bitnami/postgresql/bin:$PATH" ./configure \ + && make \ + && make install \ + && cd ~ \ + && rm -rf /tmp/citus.tar.gz /tmp/citus-${CITUS_VERSION} \ + \ + && apt-get autoremove --purge -y \ + \ + build-essential \ + libssl-dev \ + gcc \ + libc-dev \ + make \ + && apt-get clean -y \ + && rm -rf \ + /build \ + "${HOME}/.cache" \ + /var/lib/apt/lists/* \ + /tmp/* \ + /var/tmp/* + USER 1001 ENTRYPOINT [ "/opt/bitnami/scripts/postgresql/timescaledb-bitnami-entrypoint.sh" ] diff --git a/bitnami/Makefile b/bitnami/Makefile index 66d58dec..1e2e037b 100644 --- a/bitnami/Makefile +++ b/bitnami/Makefile @@ -7,6 +7,7 @@ PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-) PG_CRON_VERSION=v1.6.0 TS_VERSION=2.13.0 POSTGIS_VERSION=3.4.1 +CITUS_VERSION=12.1.0 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 = !!') PREV_TS_IMAGE="timescale/timescaledb:$(PREV_TS_VERSION)-pg$(PG_VER_NUMBER)-bitnami" 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) \ --build-arg TS_VERSION=$(TS_VERSION) \ --build-arg PREV_IMAGE=$(PREV_IMAGE) \ --build-arg PG_CRON_VERSION=$(PG_CRON_VERSION) \ - --build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) + --build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) \ + --build-arg CITUS_VERSION=$(CITUS_VERSION) default: image diff --git a/bitnami/timescaledb-bitnami-entrypoint.sh b/bitnami/timescaledb-bitnami-entrypoint.sh index 4ea4cfe1..be7c3ec6 100755 --- a/bitnami/timescaledb-bitnami-entrypoint.sh +++ b/bitnami/timescaledb-bitnami-entrypoint.sh @@ -4,9 +4,9 @@ # shared preload list, or else it gets overwritten. if [ -z "$POSTGRESQL_SHARED_PRELOAD_LIBRARIES" ] then - POSTGRESQL_SHARED_PRELOAD_LIBRARIES="timescaledb,pg_cron" + POSTGRESQL_SHARED_PRELOAD_LIBRARIES="timescaledb,pg_cron,citus" else - POSTGRESQL_SHARED_PRELOAD_LIBRARIES="$POSTGRESQL_SHARED_PRELOAD_LIBRARIES,timescaledb,pg_cron" + POSTGRESQL_SHARED_PRELOAD_LIBRARIES="$POSTGRESQL_SHARED_PRELOAD_LIBRARIES,timescaledb,pg_cron,citus" fi export POSTGRESQL_SHARED_PRELOAD_LIBRARIES