Skip to content

Commit

Permalink
Fix: Add pgvector
Browse files Browse the repository at this point in the history
  • Loading branch information
ChakshuGautam committed Apr 10, 2023
1 parent e8b2fa4 commit fb6aa89
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*~
.build_*
data
pgdata
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*~
/.build_*
*/.build_*

data
2 changes: 1 addition & 1 deletion .gitpod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ image:

tasks:
- init: echo "Building the Docker image..."
command: docker build -t merged_image .
command: PG_VERSION=15 docker build -t merged_image .

- init: echo "Running the Docker container..."
command: docker run --name merged_container -d merged_image
Expand Down
10 changes: 10 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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


37 changes: 31 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
ARG PG_VERSION
ARG PREV_IMAGE
ARG TS_VERSION
ARG PG_MAJOR=15
ARG GO_VERSION=1.18.7
ARG OSS_ONLY

############################
# Build tools binaries in separate image
############################
ARG GO_VERSION=1.18.7
FROM golang:${GO_VERSION}-alpine AS tools

ENV TOOLS_VERSION 0.8.1
Expand All @@ -19,7 +16,10 @@ RUN apk update && apk add --no-cache git gcc musl-dev \
############################
# Grab old versions from previous version
############################
ARG PG_VERSION
ARG PREV_IMAGE
FROM ${PREV_IMAGE} AS oldversions
# Remove update files, mock files, and all but the last 5 .so/.sql files
RUN rm -f $(pg_config --sharedir)/extension/timescaledb*mock*.sql \
&& if [ -f $(pg_config --pkglibdir)/timescaledb-tsl-1*.so ]; then rm -f $(ls -1 $(pg_config --pkglibdir)/timescaledb-tsl-1*.so | head -n -5); fi \
&& if [ -f $(pg_config --pkglibdir)/timescaledb-1*.so ]; then rm -f $(ls -1 $(pg_config --pkglibdir)/timescaledb-*.so | head -n -5); fi \
Expand All @@ -28,7 +28,9 @@ RUN rm -f $(pg_config --sharedir)/extension/timescaledb*mock*.sql \
############################
# Now build image and copy in tools
############################
FROM postgres:${PG_MAJOR}-alpine
ARG PG_VERSION
FROM postgres:${PG_VERSION}-alpine
ARG OSS_ONLY

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

Expand All @@ -37,6 +39,7 @@ COPY --from=tools /go/bin/* /usr/local/bin/
COPY --from=oldversions /usr/local/lib/postgresql/timescaledb-*.so /usr/local/lib/postgresql/
COPY --from=oldversions /usr/local/share/postgresql/extension/timescaledb--*.sql /usr/local/share/postgresql/extension/

ARG TS_VERSION
RUN set -ex \
&& apk add libssl1.1 \
&& apk add --no-cache --virtual .fetch-deps \
Expand Down Expand Up @@ -67,4 +70,26 @@ RUN set -ex \
\
&& if [ "${OSS_ONLY}" != "" ]; then rm -f $(pg_config --pkglibdir)/timescaledb-tsl-*.so; fi \
&& apk del .fetch-deps .build-deps \
&& rm
&& rm -rf /build \
&& sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" /usr/local/share/postgresql/postgresql.conf.sample

# Adding PG Vector

RUN cd /tmp
RUN apk add --no-cache --virtual .build-deps \
coreutils \
dpkg-dev dpkg \
gcc \
git \
krb5-dev \
libc-dev \
llvm15 \
clang \
make \
cmake \
util-linux-dev \
&& git clone --branch v0.4.1 https://github.com/pgvector/pgvector.git \
&& cd /pgvector \
&& ls \
&& make \
&& make install
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NAME=timescaledb
# Default is to timescaledev to avoid unexpected push to the main repo
# Set ORG to timescale in the caller
ORG=timescaledev
PG_VER=pg12
PG_VER=pg15
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 = !!')
Expand Down
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3.6'
services:
timescaledb:
container_name: timescaledb
image: timescaledev/timescaledb:main-pg15
restart: always
ports:
- "5432:5432"
volumes:
- ./pgdata:/var/lib/postgresql/data
environment:
POSTGRES_USER: timescaledb
POSTGRES_PASSWORD: postgrespassword

graphql-engine:
image: hasura/graphql-engine:latest
ports:
- "8080:8080"
volumes:
- ./data/migrations:/hasura-migrations
- ./data/metadata:/hasura-metadata
depends_on:
- "timescaledb"
restart: always
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://timescaledb:postgrespassword@timescaledb:5432/postgres?sslmode=disable
## enable the console served by server
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
## enable debugging mode. It is recommended to disable this in production
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup,http-log,webhook-log,websocket-log,query-log
## uncomment next line to set an admin secret
# HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
HASURA_GRAPHQL_MIGRATIONS_DISABLE_TRANSACTION: "true"
HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: /srv/console-assets

0 comments on commit fb6aa89

Please sign in to comment.