diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 00000000..fe6e7806
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,10 @@
+{
+ "name": "warsql-devcontainer",
+ "image": "samagragovernance/postgres:latest-pg15",
+ "extensions": [
+ "ms-vscode-remote.vscode-remote-extensionpack"
+ ],
+ "settings": {},
+ "forwardPorts": [5432],
+ "postCreateCommand": "pip install -r requirements.txt"
+}
diff --git a/.github/ISSUE_TEMPLATE /c4gt.md b/.github/ISSUE_TEMPLATE /c4gt.md
new file mode 100644
index 00000000..e3cbd23d
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE /c4gt.md
@@ -0,0 +1,96 @@
+---
+name: C4GT
+about: C4GT Community Issues Template
+title: "[C4GT] Button for likes"
+labels: C4GT Community
+assignees: ''
+
+---
+
+## Description
+[Provide a brief description of the feature, including why it is needed and what it will accomplish. You can skip any of Goals, Expected Outcome, Implementation Details, Mockups / Wireframes if they are irrelevant]
+
+## Goals
+- [ ] [Goal 1]
+- [ ] [Goal 2]
+- [ ] [Goal 3]
+- [ ] [Goal 4]
+- [ ] [Goal 5]
+
+## Expected Outcome
+[Describe in detail what the final product or result should look like and how it should behave.]
+
+## Acceptance Criteria
+- [ ] [Criteria 1]
+- [ ] [Criteria 2]
+- [ ] [Criteria 3]
+- [ ] [Criteria 4]
+- [ ] [Criteria 5]
+
+## Implementation Details
+[List any technical details about the proposed implementation, including any specific technologies that will be used.]
+
+## Mockups / Wireframes
+[Include links to any visual aids, mockups, wireframes, or diagrams that help illustrate what the final product should look like. This is not always necessary, but can be very helpful in many cases.]
+
+---
+
+### Project
+[Project Name]
+
+### Organization Name:
+[Organization Name]
+
+### Domain
+[Area of governance]
+
+
+
+### Tech Skills Needed:
+[Required technical skills for the project]
+
+### Mentor(s)
+[@Mentor1] [@Mentor2] [@Mentor3]
+
+### Complexity
+Pick one of [High]/[Medium]/[Low]
+
+### Category
+Pick one or more of [CI/CD], [Integrations], [Performance Improvement], [Security], [UI/UX/Design], [Bug], [Feature], [Documentation], [Deployment], [Test], [PoC]
+
+### Sub Category
+Pick one or more of [API], [Database], [Analytics], [Refactoring], [Data Science], [Machine Learning], [Accessibility], [Internationalization], [Localization], [Frontend], [Backend], [Mobile], [SEO], [Configuration], [Deprecation], [Breaking Change], [Maintenance], [Support], [Question], [Technical Debt], [Beginner friendly], [Research], [Reproducible], [Needs Reproduction].
diff --git a/.github/ISSUE_TEMPLATE/c4gt-community-ticket.md b/.github/ISSUE_TEMPLATE/c4gt-community-ticket.md
new file mode 100644
index 00000000..2b9a3fce
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/c4gt-community-ticket.md
@@ -0,0 +1,58 @@
+---
+name: C4GT Community Ticket
+about: C4GT Community Ticket
+title: C4GT
+labels: C4GT Community
+assignees: ''
+
+---
+
+## Description
+There is a need for a commenting system that will allow users to interact with the blog posts. This will increase user engagement and provide feedback to the blog authors.
+
+## Goals
+- [ ] Add a comment section to each blog post
+- [ ] Implement a moderation system for comments
+- [ ] Ensure comments are tied to a registered user
+- [ ] Implement spam and bot protection for the comments
+- [ ] Add notification system for new comments
+
+## Expected Outcome
+- Users must be registered and logged in to leave a comment.
+- Each comment should include the user's name, profile picture (if available), comment text, and timestamp.
+- Comments should be displayed in chronological order, with the most recent comment at the top.
+- An email notification should be sent to the blog post author when a new comment is made.
+- Blog post authors and administrators should be able to moderate comments (approve, deny, delete).
+
+## Acceptance Criteria
+- [ ] A registered user can submit a comment on a blog post.
+- [ ] The comment appears on the blog post after approval from the post author or administrator.
+- [ ] An email notification is sent to the blog post author when a new comment is posted.
+- [ ] Comments can be moderated by the blog post author and administrators.
+- [ ] Commenting system is resistant to spam and bot attacks.
+
+## Implementation Details
+- Leverage Django's built-in commenting framework (if applicable)
+- Use JavaScript and AJAX for real-time comment posting and updates
+- Consider integrating with a service like Akismet for spam protection
+- Use Django's built-in email function for the notification system
+
+## Mockups / Wireframes
+(Here, you can link to any visual aids, mockups, wireframes, or diagrams that help illustrate what the final product should look like. This is not always necessary, but can be very helpful in many cases.)
+
+---
+
+### Project
+OpenBlog Platform
+
+### Organization Name:
+The name of the organization proposing the project.
+
+### Domain
+The area of governance the project pertains to (ex: agri, healthcare, ed etc).
+
+### Tech Skills Needed:
+Django, Typescript, NextJS, Akismet
+
+### Mentor(s)
+@ChakshuGautam @Shruti3004 @sukhpreetssekhon
diff --git a/.github/workflows/configure_jekyll.yml b/.github/workflows/configure_jekyll.yml
new file mode 100644
index 00000000..559bddf5
--- /dev/null
+++ b/.github/workflows/configure_jekyll.yml
@@ -0,0 +1,51 @@
+# Sample workflow for building and deploying a Jekyll site to GitHub Pages
+name: Deploy Jekyll with GitHub Pages dependencies preinstalled
+
+on:
+ # Runs on pushes targeting the default branch
+ push:
+ branches: ["main"]
+
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
+permissions:
+ contents: read
+ pages: write
+ id-token: write
+
+# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
+# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
+concurrency:
+ group: "pages"
+ cancel-in-progress: false
+
+jobs:
+ # Build job
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ - name: Setup Pages
+ uses: actions/configure-pages@v3
+ - name: Build with Jekyll
+ uses: actions/jekyll-build-pages@v1
+ with:
+ source: ./
+ destination: ./_site
+ - name: Upload artifact
+ uses: actions/upload-pages-artifact@v2
+
+ # Deployment job
+ deploy:
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ runs-on: ubuntu-latest
+ needs: build
+ steps:
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v2
diff --git a/.github/workflows/image-analysis-comment.yml b/.github/workflows/image-analysis-comment.yml
new file mode 100644
index 00000000..dbf79c0b
--- /dev/null
+++ b/.github/workflows/image-analysis-comment.yml
@@ -0,0 +1,97 @@
+# image-analysis.yml and image-analysis-comment.yml workflows, are used to calculate and comment the size difference between Dockerfile in the main branch and the changes made in a pull request.
+
+name: comment Image Analysis on PR
+
+# this workflow writes all the messages present in the comment artifact to the respective Pull Request so only one parallel run is required
+concurrency:
+ group: ${{ github.workflow }}
+
+on:
+ workflow_run:
+ workflows: ["Image Analysis"]
+ types:
+ - completed
+
+jobs:
+ comment-on-pr:
+ runs-on: ubuntu-latest
+ if: >
+ github.event.workflow_run.conclusion == 'success'
+ permissions:
+ pull-requests: write
+ actions: write
+ steps:
+ - name: Download the comments list
+ id: download-artifact
+ uses: dawidd6/action-download-artifact@v2.27.0
+ with:
+ workflow: image-analysis.yml
+ name: image-analysis-comments
+ check_artifacts: true
+ search_artifacts: true
+ if_no_artifact_found: fail
+
+ # set up dependency for github scripts
+ - uses: actions/setup-node@v3
+ with:
+ node-version: 16
+ - run: |
+ npm install fs
+
+ - name: Comment on PR
+ uses: actions/github-script@v3
+ with:
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ script: |
+ // Modified from https://github.com/kanga333/comment-hider
+ async function hideComment(issueNumber,userName,reason){
+ const comments = await github.issues.listComments({
+ owner:context.repo.owner,
+ repo:context.repo.repo,
+ issue_number: issueNumber
+ });
+ const ids = [];
+ for (const r of comments.data) {
+ if (r.user !== null && r.user.login !== userName) {
+ continue;
+ }
+ ids.push(r.node_id);
+ }
+ ids.splice(-1,1);
+ for ( let id of ids){
+ const resp = await github.graphql(`
+ mutation {
+ minimizeComment(input: {classifier: ${reason}, subjectId: "${id}"}) {
+ minimizedComment {
+ isMinimized
+ }
+ }
+ }
+ `);
+
+ if (resp.errors) {
+ core.setFailed(`${resp.errors[0].message}`);
+ }
+ }
+ }
+ var fs = require('fs');
+ var comments = JSON.parse(fs.readFileSync('./comments.json'));
+ console.log(comments);
+ while (comments.length > 0) {
+ const comment = comments[0];
+ hideComment(comment.issue_number,'github-actions[bot]','OUTDATED') ;
+ await github.issues.createComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: comment.issue_number,
+ body: comment.body
+ });
+ comments.shift();
+ }
+
+ - name: Delete the comment list
+ uses: jimschubert/delete-artifacts-action@v1
+ with:
+ log_level: "debug"
+ artifact_name: image-analysis-comments
+ min_bytes: "0"
diff --git a/.github/workflows/image-analysis.yml b/.github/workflows/image-analysis.yml
new file mode 100644
index 00000000..71336b23
--- /dev/null
+++ b/.github/workflows/image-analysis.yml
@@ -0,0 +1,112 @@
+# image-analysis.yml and image-analysis-comment.yml workflows, are used to calculate and comment the size difference between Dockerfiles in the main branch and the changes made in a pull request.
+name: Image Analysis
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+on:
+ workflow_run:
+ workflows: ["Smoke Test Docker Image"]
+ types: [completed]
+
+env:
+ ORG: timescaledev
+ TS_VERSION: main
+ PLATFORM: linux/amd64
+
+jobs:
+ image-analysis:
+ name: PG${{ matrix.pg }}-${{ matrix.type }}-analysis
+ runs-on: ubuntu-latest
+ permissions:
+ actions: write #write permission is need to delete actions
+ strategy:
+ max-parallel: 1 # Running sequentially to add comments to the comment artifact without overwriting
+ fail-fast: false
+ matrix:
+ pg: [15]
+ type: ["bitnami", "normal"]
+ if: ${{ github.event.workflow_run.conclusion == 'success' }}
+ steps:
+ - name: Check out the source
+ uses: actions/checkout@v3
+
+ - name: Download image built from the PR
+ uses: dawidd6/action-download-artifact@v2.27.0
+ with:
+ workflow: smoke-test.yml
+ name: ${{matrix.type}}-${{ github.event.workflow_run.head_sha }}
+ check_artifacts: true
+ search_artifacts: true
+ if_no_artifact_found: fail
+ skip_unpack: true # Docker images are too big to unpack with this action
+ - name: unzip the image artifact
+ run: |
+ unzip ${{matrix.type}}-${{ github.event.workflow_run.head_sha }}.zip
+
+ - name: Load image into docker
+ run: |
+ cat ./${{matrix.type}}-${{ github.event.workflow_run.head_sha }}.tar | docker import - smoketest-image
+
+ # set up dependency for github scripts
+ - uses: actions/setup-node@v3
+ with:
+ node-version: 16
+ - run: |
+ npm install fs
+
+ - name: Download metrics of main branch
+ if: github.event.workflow_run.event == 'pull_request'
+ uses: dawidd6/action-download-artifact@v2.27.0
+ with:
+ workflow: image-analysis.yml
+ name: image-metric-${{matrix.type}}
+ check_artifacts: true
+ search_artifacts: true
+ if_no_artifact_found: warn
+
+ - name: Download comments artifact
+ if: github.event.workflow_run.event == 'pull_request'
+ uses: dawidd6/action-download-artifact@v2.27.0
+ with:
+ workflow: image-analysis.yml
+ name: image-analysis-comments
+ check_artifacts: true
+ search_artifacts: true
+ workflow_conclusion: "" # Consider current successful runs of matrix jobs
+ if_no_artifact_found: warn
+
+ - name: Analyse image
+ uses: actions/github-script@v6.4.1
+ with:
+ workspace: ${{ github.workspace }}
+ image-type: ${{matrix.type}}
+ script: |
+ const fs = require('fs')
+ const script = require('./image_size.js')
+ console.log(script({github, context, exec,core,fs}))
+
+ - name: Upload the updated comments
+ uses: actions/upload-artifact@v3
+ if: github.event.workflow_run.event == 'pull_request'
+ with:
+ name: image-analysis-comments
+ path: comments.json
+ if-no-files-found: error
+
+ - name: Upload metrics from main branch
+ uses: actions/upload-artifact@v3
+ if: github.event.workflow_run.event == 'push'
+ with:
+ name: image-metric-${{matrix.type}}
+ path: image-metrics-${{matrix.type}}.json
+ if-no-files-found: error
+
+
+ - name: Delete docker image artifact
+ uses: jimschubert/delete-artifacts-action@v1
+ with:
+ log_level: "debug"
+ artifact_name: ${{matrix.type}}-${{ github.event.workflow_run.head_sha }}
+ min_bytes: "0"
diff --git a/.github/workflows/smoke-test-packer.yml b/.github/workflows/smoke-test-packer.yml
new file mode 100644
index 00000000..504cd8d0
--- /dev/null
+++ b/.github/workflows/smoke-test-packer.yml
@@ -0,0 +1,129 @@
+name: Smoke Test packer template
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+on:
+ pull_request:
+ push:
+ branches:
+ - main
+
+env:
+ ORG: timescaledev
+ TS_VERSION: main
+ PLATFORM: linux/amd64
+
+jobs:
+ smoketest-all:
+ name: PG${{ matrix.pg }}-${{ matrix.type }}-paacker
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ pg: [15]
+ type: ['alpine', 'bitnami']
+ steps:
+ - name: Check out the source
+ uses: actions/checkout@v3
+
+
+ - name: Build packer template
+ run: |
+ cd packer
+ PACKER_LOG=1 packer init . && packer build -only 'warpsql.docker.${{matrix.type}}' -var image_repository=smoketest-image warpsql.pkr.hcl
+
+ - name: Install psql
+ run: sudo apt install postgresql-client
+
+ - name: Run the smoke test
+ run: |
+ set -eu
+ export PGHOST=localhost
+ export PGUSER=postgres
+ export PGPASSWORD=test1234
+ docker container stop smoketest-container || true
+ docker container rm smoketest-container || true
+ docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=${PGPASSWORD} --name smoketest-container smoketest-image:latest
+ for _ in {1..120}
+ do
+ if [ -z "$(docker container ls -q --filter name=smoketest-container)" ]
+ then
+ echo "Smoketest container is not running"
+ exit 1
+ fi
+ if psql -c "select 1"
+ then
+ bash ./test/smoke_test/smoke_test.sh
+ break
+ fi
+ sleep 1
+ done
+ if ! psql -c "select 1"
+ then
+ echo "Cannot connect to PostgreSQL"
+ exit 1
+ fi
+
+ - name: Show the logs
+ if: always()
+ run: |
+ docker logs smoketest-container
+
+ smoketest-individual:
+ name: PG${{ matrix.pg }}-${{ matrix.type }}-${{matrix.extention}}-packer
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ max-parallel: 5
+ matrix:
+ pg: [15]
+ type: ['alpine', 'bitnami']
+ extention: ['timescaledb','pgvector','postgis','zombodb','pg_repack','pgautofailover','hll','citus']
+ steps:
+ - name: Check out the source
+ uses: actions/checkout@v3
+
+
+ - name: Build packer template
+ run: |
+ cd packer
+ PACKER_LOG=1 packer init . && packer build -only 'warpsql.docker.${{matrix.type}}' -var image_repository=smoketest-image -var extentions='${{matrix.extention}}' warpsql.pkr.hcl
+
+ - name: Install psql
+ run: sudo apt install postgresql-client
+
+ - name: Run the smoke test
+ run: |
+ set -eu
+ export PGHOST=localhost
+ export PGUSER=postgres
+ export PGPASSWORD=test1234
+ docker container stop smoketest-container || true
+ docker container rm smoketest-container || true
+ docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=${PGPASSWORD} --name smoketest-container smoketest-image:latest
+ for _ in {1..120}
+ do
+ if [ -z "$(docker container ls -q --filter name=smoketest-container)" ]
+ then
+ echo "Smoketest container is not running"
+ exit 1
+ fi
+ if psql -c "select 1"
+ then
+ bash ./test/smoke_test/smoke_test.sh "${{matrix.extention}}"
+ break
+ fi
+ sleep 1
+ done
+ if ! psql -c "select 1"
+ then
+ echo "Cannot connect to PostgreSQL"
+ exit 1
+ fi
+
+ - name: Show the logs
+ if: always()
+ run: |
+ docker logs smoketest-container
diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml
index e5151234..384f54e6 100644
--- a/.github/workflows/smoke-test.yml
+++ b/.github/workflows/smoke-test.yml
@@ -1,4 +1,9 @@
name: Smoke Test Docker Image
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
on:
pull_request:
push:
@@ -12,24 +17,37 @@ env:
jobs:
smoketest:
- name: PG${{ matrix.pg }}-${{ matrix.type }}
+ name: PG${{ matrix.pg }}-${{ matrix.type }}-docker
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pg: [15]
- type: ['normal', 'bitnami']
+ type: ["normal", "bitnami"]
steps:
+ - name: set the correct commit sha
+ env:
+ EVENT: ${{github.event_name}}
+ run: |
+ if [ "$EVENT" == 'pull_request' ]
+ then
+ echo "commit=${{ github.event.pull_request.head.sha}}" >> "$GITHUB_ENV"
+ else
+ echo "commit=${{ github.sha}}" >> "$GITHUB_ENV"
+ fi
- name: Check out the source
uses: actions/checkout@v3
+ - name: Expose GitHub Runtime
+ uses: crazy-max/ghaction-github-runtime@v2
+
- name: Build Docker Image for TimescaleDB
run: |
if [ ${{ matrix.type }} == bitnami ]
then
cd bitnami
fi
- make image PG_VER=pg${{ matrix.pg }} TAG_VERSION=smoketest-image BETA=1
+ make build-docker-cache image PG_VER=pg${{ matrix.pg }} TAG_VERSION=smoketest-image BETA=1
- name: Install psql
run: sudo apt install postgresql-client
@@ -52,6 +70,7 @@ jobs:
fi
if psql -c "select 1"
then
+ bash ./test/smoke_test/smoke_test.sh
break
fi
sleep 1
@@ -66,3 +85,21 @@ jobs:
if: always()
run: |
docker logs smoketest-container
+
+ - name: export the image
+ run: |
+ set -eux
+ export PGHOST=localhost
+ export PGUSER=postgres
+ export PGPASSWORD=test1234
+ docker container stop smoketest-container || true
+ docker container rm smoketest-container || true
+ docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=${PGPASSWORD} --name smoketest-container smoketest-image
+ docker export smoketest-container > ${{matrix.type}}-${{ env.commit }}.tar
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v3
+ with:
+ name: ${{matrix.type}}-${{ env.commit }}
+ path: ./${{matrix.type}}-${{ env.commit }}.tar
+ retention-days: 1
diff --git a/.gitpod.yml b/.gitpod.yml
deleted file mode 100644
index 63a3e4fd..00000000
--- a/.gitpod.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-# This configuration file was automatically generated by Gitpod.
-# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
-# and commit this file to your remote git repository to share the goodness with others.
-
-# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart
-
-tasks:
- - init: make
-
-
diff --git a/Dockerfile b/Dockerfile
index 78d8c632..f8f694a5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -73,6 +73,9 @@ RUN set -ex \
&& rm -rf /build \
&& sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" /usr/local/share/postgresql/postgresql.conf.sample
+# Update to shared_preload_libraries
+RUN echo "shared_preload_libraries = 'citus,timescaledb,pg_stat_statements,pgautofailover'" >> /usr/local/share/postgresql/postgresql.conf.sample
+
# Adding PG Vector
RUN cd /tmp
@@ -84,12 +87,257 @@ RUN apk add --no-cache --virtual .build-deps \
krb5-dev \
libc-dev \
llvm15 \
- clang \
make \
cmake \
+ clang15 \
util-linux-dev \
&& git clone --branch v0.4.1 https://github.com/pgvector/pgvector.git \
&& cd /pgvector \
&& ls \
&& make \
&& make install
+
+## Adding Citus
+
+# Install Citus dependencies
+RUN apk add --no-cache --virtual .citus-deps \
+ curl \
+ jq
+
+# Install Citus
+ARG CITUS_VERSION
+RUN set -ex \
+ && apk add --no-cache --virtual .citus-build-deps \
+ gcc \
+ libc-dev \
+ make \
+ curl-dev \
+ lz4-dev \
+ zstd-dev \
+ clang \
+ 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
+
+
+ARG POSTGIS_VERSION
+ARG POSTGIS_SHA256
+
+RUN set -eux \
+ \
+ && if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \
+ set -eux ; \
+ export GEOS_ALPINE_VER=3.11 ; \
+ export GDAL_ALPINE_VER=3.6.4-r4 ; \
+ export PROJ_ALPINE_VER=9.2 ; \
+ elif [ $(printf %.1s "$POSTGIS_VERSION") == 2 ]; then \
+ set -eux ; \
+ export GEOS_ALPINE_VER=3.8 ; \
+ export GDAL_ALPINE_VER=3.2 ; \
+ export PROJ_ALPINE_VER=7.2 ; \
+ \
+ echo 'https://dl-cdn.alpinelinux.org/alpine/v3.14/main' >> /etc/apk/repositories ; \
+ echo 'https://dl-cdn.alpinelinux.org/alpine/v3.14/community' >> /etc/apk/repositories ; \
+ echo 'https://dl-cdn.alpinelinux.org/alpine/v3.13/main' >> /etc/apk/repositories ; \
+ echo 'https://dl-cdn.alpinelinux.org/alpine/v3.13/community' >> /etc/apk/repositories ; \
+ \
+ else \
+ set -eux ; \
+ echo ".... unknown \$POSTGIS_VERSION ...." ; \
+ exit 1 ; \
+ fi \
+ \
+ && apk add --no-cache --virtual .fetch-deps \
+ ca-certificates \
+ openssl \
+ tar \
+ \
+ && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \
+ && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \
+ && mkdir -p /usr/src/postgis \
+ && tar \
+ --extract \
+ --file postgis.tar.gz \
+ --directory /usr/src/postgis \
+ --strip-components 1 \
+ && rm postgis.tar.gz \
+ \
+ && apk add --no-cache --virtual .build-deps \
+ \
+ gdal-dev~=${GDAL_ALPINE_VER} \
+ geos-dev~=${GEOS_ALPINE_VER} \
+ proj-dev~=${PROJ_ALPINE_VER} \
+ \
+ autoconf \
+ automake \
+ clang-dev \
+ clang15 \
+ cunit-dev \
+ file \
+ g++ \
+ gcc \
+ gettext-dev \
+ git \
+ json-c-dev \
+ libtool \
+ libxml2-dev \
+ llvm-dev \
+ llvm15 \
+ make \
+ pcre-dev \
+ perl \
+ protobuf-c-dev \
+ \
+# build PostGIS
+ \
+ && cd /usr/src/postgis \
+ && gettextize \
+ && ./autogen.sh \
+ && ./configure \
+ --with-pcredir="$(pcre-config --prefix)" \
+ && make -j$(nproc) \
+ && make install \
+ \
+# add .postgis-rundeps
+ && apk add --no-cache --virtual .postgis-rundeps \
+ \
+ gdal~=${GDAL_ALPINE_VER} \
+ geos~=${GEOS_ALPINE_VER} \
+ proj~=${PROJ_ALPINE_VER} \
+ \
+ json-c \
+ libstdc++ \
+ pcre \
+ protobuf-c \
+ \
+ ca-certificates \
+# clean
+ && cd / \
+ && rm -rf /usr/src/postgis \
+ && apk del .fetch-deps .build-deps
+
+ENV RUSTFLAGS="-C target-feature=-crt-static"
+ARG PG_VER
+RUN apk add --no-cache --virtual .zombodb-build-deps \
+ git \
+ curl \
+ bash \
+ ruby-dev \
+ ruby-etc \
+ musl-dev \
+ make \
+ gcc \
+ coreutils \
+ util-linux-dev \
+ musl-dev \
+ openssl-dev \
+ clang15 \
+ tar \
+ && gem install --no-document fpm \
+ && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y \
+ && PATH=$HOME/.cargo/bin:$PATH \
+ && cargo install cargo-pgrx --version 0.9.3 \
+ && cargo pgrx init --${PG_VER}=$(which pg_config) \
+ && git clone https://github.com/zombodb/zombodb.git \
+ && cd ./zombodb \
+ && cargo pgrx install --release \
+ && cd .. \
+ && rm -rf ./zombodb \
+ && apk del .zombodb-build-deps
+
+## Adding pg_repack
+ARG PG_REPACK_VERSION
+RUN set -eux \
+ && apk add --no-cache --virtual .pg_repack-build-deps \
+ openssl-dev \
+ zstd-dev \
+ lz4-dev \
+ zlib-dev \
+ make \
+ clang15 \
+ gawk \
+ llvm15 \
+ gcc \
+ musl-dev \
+# build pg_repack
+ && wget -O /tmp/pg_repack-${PG_REPACK_VERSION}.zip "https://api.pgxn.org/dist/pg_repack/${PG_REPACK_VERSION}/pg_repack-${PG_REPACK_VERSION}.zip" \
+ && unzip /tmp/pg_repack-${PG_REPACK_VERSION}.zip -d /tmp \
+ && cd /tmp/pg_repack-${PG_REPACK_VERSION} \
+ && make \
+ && make install \
+# clean
+ && cd / \
+ && rm -rf /tmp/pg_repack-${PG_REPACK_VERSION} /tmp/pg_repack.zip \
+ && apk del .pg_repack-build-deps
+
+# Adding pgautofailover
+ARG PG_AUTO_FAILOVER_VERSION
+RUN set -eux \
+ && apk add --no-cache --virtual .pg_auto_failover-build-deps \
+ make \
+ gcc \
+ musl-dev \
+ krb5-dev \
+ openssl-dev \
+ clang15 \
+ ncurses-dev \
+ linux-headers \
+ zstd-dev \
+ lz4-dev \
+ zlib-dev \
+ libedit-dev \
+ libxml2-utils \
+ libxslt-dev \
+ llvm15 \
+# build pg_auto_failover
+ && wget -O /tmp/pg_auto_failover-${PG_AUTO_FAILOVER_VERSION}.zip "https://github.com/hapostgres/pg_auto_failover/archive/refs/tags/v${PG_AUTO_FAILOVER_VERSION}.zip" \
+ && unzip /tmp/pg_auto_failover-${PG_AUTO_FAILOVER_VERSION}.zip -d /tmp \
+ && ls -alh /tmp \
+ && cd /tmp/pg_auto_failover-${PG_AUTO_FAILOVER_VERSION} \
+ && make \
+ && make install \
+# clean
+ && cd / \
+ && rm -rf /tmp/pg_auto_failove-${PG_AUTO_FAILOVER_VERSION} /tmp/pg_auto_failove-${PG_AUTO_FAILOVER_VERSION}.zip \
+ && apk del .pg_auto_failover-build-deps
+
+
+## Adding postgresql-hll
+ARG POSTGRES_HLL_VERSION
+RUN set -eux \
+ && apk add --no-cache --virtual .postgresql-hll-build-deps \
+ openssl-dev \
+ zstd-dev \
+ lz4-dev \
+ zlib-dev \
+ make \
+ git \
+ clang15 \
+ gawk \
+ llvm15 \
+ g++ \
+ musl-dev \
+# build postgresql-hll
+ && wget -O /tmp/postgresql-hll-${POSTGRES_HLL_VERSION}.zip "https://github.com/citusdata/postgresql-hll/archive/refs/tags/v${POSTGRES_HLL_VERSION}.zip" \
+ && unzip /tmp/postgresql-hll-${POSTGRES_HLL_VERSION}.zip -d /tmp \
+ && cd /tmp/postgresql-hll-${POSTGRES_HLL_VERSION} \
+ && make \
+ && make install \
+# clean
+ && cd / \
+ && rm -rf /tmp/postgresql-hll-${POSTGRES_HLL_VERSION} /tmp/postgresql-hll-${POSTGRES_HLL_VERSION}.zip \
+ && apk del .postgresql-hll-build-deps
+
diff --git a/Makefile b/Makefile
index 0e6d6029..181317ff 100644
--- a/Makefile
+++ b/Makefile
@@ -3,11 +3,17 @@ NAME=postgres
# Set ORG to timescale in the caller
ORG=samagragovernance
PG_VER=pg15
+CITUS_VERSION="11.2.0"
+POSTGIS_VERSION=3.3.2
+PG_REPACK_VERSION = 1.4.8
+PG_AUTO_FAILOVER_VERSION = 2.0
+POSTGRES_HLL_VERSION = 2.17
+POSTGIS_SHA256=2a6858d1df06de1c5f85a5b780773e92f6ba3a5dc09ac31120ac895242f5a77b
PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-)
TS_VERSION=main
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 )
+PREV_TS_IMAGE="samagragovernance/postgres:$(PREV_TS_VERSION)-pg$(PG_VER_NUMBER)$(PREV_EXTRA)"
+PREV_IMAGE=$(shell if docker pull "$(PREV_TS_IMAGE)" >/dev/null 2>&1; then echo "$(PREV_TS_IMAGE)"; else echo "timescale/timescaledb:$(PREV_TS_VERSION)-pg$(PG_VER_NUMBER)$(PREV_EXTRA)"; fi )
# Beta releases should not be tagged as latest, so BETA is used to track.
BETA=$(findstring rc,$(TS_VERSION))
PLATFORM=linux/amd64,linux/arm64
@@ -19,6 +25,18 @@ TAG_LATEST=$(ORG)/$(NAME):latest-$(PG_VER)
TAG=-t $(TAG_VERSION) $(if $(BETA),,-t $(TAG_LATEST))
TAG_OSS=-t $(TAG_VERSION)-oss $(if $(BETA),,-t $(TAG_LATEST)-oss)
+DOCKER_BUILD_ARGS = --build-arg PG_VERSION=$(PG_VER_NUMBER) \
+ --build-arg TS_VERSION=$(TS_VERSION) \
+ --build-arg PREV_IMAGE=$(PREV_IMAGE) \
+ --build-arg CITUS_VERSION=$(CITUS_VERSION) \
+ --build-arg PG_VER=$(PG_VER) \
+ --build-arg PG_REPACK_VERSION=$(PG_REPACK_VERSION) \
+ --build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) \
+ --build-arg PG_AUTO_FAILOVER_VERSION=$(PG_AUTO_FAILOVER_VERSION) \
+ --build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) \
+ --build-arg POSTGIS_SHA256=$(POSTGIS_SHA256) \
+ --build-arg POSTGRES_HLL_VERSION=$(POSTGRES_HLL_VERSION)
+
default: image
.multi_$(TS_VERSION)_$(PG_VER)_oss: Dockerfile
@@ -54,7 +72,12 @@ default: image
touch .build_$(TS_VERSION)_$(PG_VER)_oss
.build_$(TS_VERSION)_$(PG_VER): Dockerfile
- docker build --build-arg PG_VERSION=$(PG_VER_NUMBER) --build-arg TS_VERSION=$(TS_VERSION) --build-arg PREV_IMAGE=$(PREV_IMAGE) $(TAG) .
+ docker build $(DOCKER_BUILD_ARGS) $(TAG) .
+ touch .build_$(TS_VERSION)_$(PG_VER)
+
+build-docker-cache: Dockerfile
+ docker buildx create --use --driver=docker-container
+ docker buildx build --progress=plain --load --cache-to "type=gha,mode=max" --cache-from type=gha $(DOCKER_BUILD_ARGS) $(TAG) .
touch .build_$(TS_VERSION)_$(PG_VER)
image: .build_$(TS_VERSION)_$(PG_VER)
@@ -83,4 +106,4 @@ clean:
rm -f *~ .build_* .multi_*
-docker buildx rm multibuild
-.PHONY: default image push push-oss oss multi multi-oss clean all
+.PHONY: default image push push-oss oss multi multi-oss clean all build-docker-cache
diff --git a/README.md b/README.md
index 41678219..a0248259 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,192 @@
-## Test on GitPod
-[](https://gitpod.io/#https://github.com/ChakshuGautam/postgres-tsdb-vector-docker)
+
+
WarpSQL
+Opinionated extensions to Postgres packaged as a single docker deployment. Why install 10 DBs when you can have everything at once (maybe not everything).
+
+Certified as Indie Hacker's best friend!!!
-## Postgres
+### Current and future supported extensions
- [x] [PgVector](https://github.com/pgvector/pgvector)
- [x] [TimescaleDB](https://github.com/timescale/timescaledb)
-- [ ] [Citus](https://www.citusdata.com/)
+- [x] [Citus](https://www.citusdata.com/)
+- [x] [PostGIS](https://postgis.net)
+- [x] [ZomboDB](https://github.com/zombodb/zombodb)
+- [ ] [PLV8](https://github.com/plv8/plv8)
+- [ ] [Pg Repack](https://github.com/reorg/pg_repack)
Bootstrapped from [TimescaleDB](https://github.com/timescale/timescaledb-docker)
+
+### Usage with Compose
+
+```yaml
+version: '3.6'
+services:
+ warpsql:
+ container_name: warpsql
+ image: samagragovernance/postgres:latest-pg15
+ restart: always
+ ports:
+ - "5432:5432"
+ volumes:
+ - ./pgdata:/var/lib/postgresql/data
+ environment:
+ POSTGRES_USER: warpSQLUser
+ POSTGRES_PASSWORD: warpSQLPass
+```
+
+WarpSQL is a powerful solution that provides opinionated extensions to Postgres, conveniently packaged as a single Docker deployment. It eliminates the need to install multiple separate databases by offering a comprehensive set of features in one place (although not everything, as some features might not be included).
+
+By utilizing WarpSQL, you can benefit from the following:
+
+- *Simplified setup*: With WarpSQL, you can have all the necessary extensions for your Postgres database in one go, saving you time and effort.
+- *Seamless integration*: WarpSQL includes popular extensions like PgVector, TimescaleDB, Citus, and PostGIS, allowing you to leverage their functionality seamlessly.
+- *Enhanced performance*: The included extensions are carefully selected to optimize database performance, enabling you to work efficiently with large datasets.
+- *Extensibility*: While WarpSQL already supports a range of extensions, it aims to expand its offerings to include even more powerful tools in the future, such as ZomboDB, PLV8, and Pg Repack.
+Get started with WarpSQL today and experience the convenience of a comprehensive Postgres solution.
+
+## PostgreSQL Image Packer Template
+
+This repository contains a Packer template for building the WarpSQL image with multiple sources and provisioners. The template supports building images based on both the Alpine and Bitnami PostgreSQL images.
+
+#### Prerequisites
+
+Before using this Packer template, ensure that you have the following prerequisites installed:
+
+- [Packer](https://www.packer.io/)
+- [Docker](https://www.docker.com/) (for building Docker images)
+
+### Usage
+
+To build the WarpSQL image using the Packer template, follow these steps:
+
+1. Clone this repository and navigate to the packer directory:
+
+ ```shell
+ git clone https://github.com/Samagra-Development/WarpSQL.git
+ cd WarpSQL/packer
+2. Build the images:
+ ```shell
+ packer build warpsql.pkr.hcl
+ ```
+To build only the Alpine image, you can use the `-only` option:
+
+ ```shell
+ packer build -only=warpsql.docker.alpine warpsql.pkr.hcl
+ ```
+ By default, all supported [extensions](#list-of-supported-extensions) are installed. If you want to install specific extensions, you can provide the `extensions` variable:
+ ```shell
+ packer build -var extentions='pg_repack,hll' -only warpsql.docker.alpine warpsql.pkr.hcl
+ ```
+
+ Note that currently only the `Docker` source has been added to the template.
+
+You can further customize the image repository and tags by providing values for the `image_repository` and `image_tags` variables using the `-var` option. Here's an example command:
+```shell
+packer build -var="image_repository=your_value" -var="image_tags=[tag1,tag2]" warpsql.pkr.hcl
+```
+
+### List of supported extensions
+|Extension | Identifier |
+|----------------|------------------|
+|[PgVector](https://github.com/pgvector/pgvector) | `pgvector` |
+|[TimescaleDB](https://github.com/timescale/timescaledb) | `timescaledb` |
+|[Citus](https://github.com/citusdata/citus) | `citus` |
+|[PostGIS](https://github.com/postgis/postgis) | `postgis` |
+|[ZomboDB](https://github.com/zombodb/zombodb) | `zombodb` |
+|[PgRepack](https://github.com/reorg/pg_repack) | `pg_repack` |
+|[PG Auto Failover](https://github.com/hapostgres/pg_auto_failover)| `pgautofailover` |
+|[HyperLogLog](https://github.com/citusdata/postgresql-hll) | `hll` |
+### AWS
+WarpSQL provides a streamlined approach to deploying and managing PostgreSQL databases on AWS EC2 instances, complete with a disaster recovery solution powered by Barman.
+> **Warning**
+WarpSQL is a work in progress, and the current setup allows public SSH access to instances, which might not be secure.
+
+
+To get started, ensure you have your AWS credentials set up and Docker,Terraform installed.
+
+First, create Docker images using the provided Dockerfiles in the `barman` and `warpsql_ssh` directories. Once built, push these images to a public image repository.
+Specify the repository where you pushed these Docker images by passing the repository URL as a variable in the Terraform command.
+
+To launch WarpSQL with Barman, run:
+```shell
+git clone https://github.com/Samagra-Development/WarpSQL.git
+cd WarpSQL/terraform/aws
+terraform apply -var img_warpsql= -var img_barman=
+```
+
+You can also set the password for the Postgres instance by using the `warpsql_password` variable in the Terraform script the default value is `warpsql`.
+
+This will initiate the deployment of three EC2 instances that include an Ansible controller, PostgreSQL and Barman Docker containers.These instances are provisioned on an Ubuntu Host OS and are fully configured, requiring no further setup on your end.
+
+During any subsequent launches of the WarpSQL instance, the data is recovered from the latest backup stored by Barman.
+
+To specify the size of each instance's disk, provide the desired size in gigabytes to the respective variables: `warpsql_disk_size`, `ansible_disk_size`, and `barman_disk_size` in the terraform script.
+
+
+The Barman images are based on [ubc/barman-docker](https://github.com/ubc/barman-docker). By default, Barman performs a base backup according to the cron schedule `0 4 * * *`. If you need to modify this schedule, refer to the environment variables documentation at https://github.com/ubc/barman-docker#environment-variables.
+
+## Contribution
+
+You can contribute to the development of WarpSQL using both Gitpod and Codespaces. Follow the steps below to set up your development environment and make contributions:
+
+### Gitpod
+
+Click the "Open in Gitpod" button above or use the following link:[Open in Gitpod](https://gitpod.io/new/#https://github.com/ChakshuGautam/postgres-tsdb-vector-docker)
+
+[](https://gitpod.io/#https://github.com/ChakshuGautam/postgres-tsdb-vector-docker)
+
+- Wait for the Gitpod environment to be created and initialized.
+- Once the environment is ready, you can start working on the project.
+- Make your desired changes or additions.
+- Test your changes and ensure they meet the project's guidelines.
+- Commit and push your changes to your forked repository.
+- Create a pull request from your forked repository to the main WarpSQL repository.
+
+### GitHub Codespaces
+
+You can use GitHub Codespaces to develop this project in the cloud.
+
+[](https://github.com/features/codespaces)
+
+- Click on the "Code" button.
+- Select "Open with Codespaces" from the dropdown menu.
+- Choose the appropriate Codespace configuration.
+- Wait for the environment to be provisioned.
+
+Once the environment is ready, you can start working on the project.
+
+- Make your desired changes or additions.
+- Test your changes and ensure they meet the project's guidelines.
+- Commit and push your changes to your forked repository.
+- Create a pull request from your forked repository to the main WarpSQL repository.
+- We welcome contributions from the community and appreciate your support in improving WarpSQL!
+
+### Ensure CI passes 
+
+Before merging any contributions or changes, it's essential to ensure that the continuous integration (CI) tests pass successfully. CI helps maintain code quality standards and prevents the introduction of regressions. To ensure a smooth integration process, follow these steps:
+
+- Make your desired changes or additions to the codebase.
+- Run the relevant tests locally to verify that your changes are functioning as expected.
+- Push your changes to the branch you're working on.
+- The CI system will automatically run tests and checks on your code.
+- Monitor the CI build status to ensure that all tests pass successfully.
+- If the CI build fails, review the error messages and make the necessary fixes.
+- Repeat steps 3-6 until the CI build passes successfully.
+- Once the CI build is successful, you can proceed with merging your changes into the main WarpSQL repository.
+
+## Maintainers
+
+
+
+
+