Skip to content

Commit

Permalink
Add plpython3, pgvector, and pgai extensions (#249)
Browse files Browse the repository at this point in the history
- Remove support for pg13
- Add plpython3
- Add pgvector
- Add pgai on pg16+
  • Loading branch information
jgpruitt committed Jun 7, 2024
1 parent 4dbc2cb commit 20e456c
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*~
.build_*
.github
.idea
2 changes: 1 addition & 1 deletion .github/workflows/bitnami.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
pg: [13, 14, 15, 16]
pg: [14, 15, 16]
base-image: [postgresql, postgresql-repmgr]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
pg: [13, 14, 15, 16]
pg: [14, 15, 16]
oss: [ "", "-oss" ]
steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
/.build_*
*/.build_*
.idea
40 changes: 38 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,55 @@ RUN rm -f $(pg_config --sharedir)/extension/timescaledb*mock*.sql
# Now build image and copy in tools
############################
ARG PG_VERSION
FROM postgres:${PG_VERSION}-alpine3.18
FROM postgres:${PG_VERSION}-alpine3.20
ARG OSS_ONLY

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

ARG PG_VERSION
RUN set -ex; \
apk update; \
apk add --no-cache \
postgresql${PG_VERSION}-plpython3

ARG PGVECTOR_VERSION
RUN set -ex; \
apk update; \
apk add --no-cache --virtual .vector-deps \
postgresql${PG_VERSION}-dev \
git \
build-base \
clang15 \
llvm15-dev \
llvm15; \
git clone --branch ${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git /build/pgvector; \
cd /build/pgvector; \
make; \
make install; \
apk del .vector-deps

# install pgai only on pg16+
ARG PGAI_VERSION
RUN set -ex; \
if [ "$PG_VERSION" -gt 15 ]; then \
apk add --no-cache --virtual .pgai-deps \
git \
py3-pip; \
git clone --branch ${PGAI_VERSION} https://github.com/timescale/pgai.git /build/pgai; \
cd /build/pgai; \
cp /build/pgai/ai--*.sql /usr/local/share/postgresql/extension/; \
cp /build/pgai/ai.control /usr/local/share/postgresql/extension/; \
pip install --break-system-packages -r /build/pgai/requirements.txt; \
apk del .pgai-deps; \
fi

COPY docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d/
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 \
ca-certificates \
git \
Expand Down
13 changes: 10 additions & 3 deletions 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=pg16
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 All @@ -19,6 +19,9 @@ 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)

PGVECTOR_VERSION=v0.7.1
PGAI_VERSION=v0.1.0

default: image

.multi_$(TS_VERSION)_$(PG_VER)_oss: Dockerfile
Expand All @@ -31,6 +34,8 @@ default: image
--build-arg PG_VERSION=$(PG_VER_NUMBER) \
--build-arg PREV_IMAGE=$(PREV_IMAGE) \
--build-arg OSS_ONLY=" -DAPACHE_ONLY=1" \
--build-arg PGVECTOR_VERSION=$(PGVECTOR_VERSION) \
--build-arg PGAI_VERSION=$(PGAI_VERSION) \
$(TAG_OSS) $(PUSH_MULTI) .
touch .multi_$(TS_VERSION)_$(PG_VER)_oss
docker buildx rm multibuild
Expand All @@ -45,16 +50,18 @@ default: image
--build-arg TS_VERSION=$(TS_VERSION) \
--build-arg PREV_IMAGE=$(PREV_IMAGE) \
--build-arg PG_VERSION=$(PG_VER_NUMBER) \
--build-arg PGVECTOR_VERSION=$(PGVECTOR_VERSION) \
--build-arg PGAI_VERSION=$(PGAI_VERSION) \
$(TAG) $(PUSH_MULTI) .
touch .multi_$(TS_VERSION)_$(PG_VER)
docker buildx rm multibuild

.build_$(TS_VERSION)_$(PG_VER)_oss: Dockerfile
docker build --build-arg OSS_ONLY=" -DAPACHE_ONLY=1" --build-arg PG_VERSION=$(PG_VER_NUMBER) $(TAG_OSS) .
docker build --build-arg OSS_ONLY=" -DAPACHE_ONLY=1" --build-arg PG_VERSION=$(PG_VER_NUMBER) --build-arg PGVECTOR_VERSION=$(PGVECTOR_VERSION) --build-arg PGAI_VERSION=$(PGAI_VERSION) $(TAG_OSS) .
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 --build-arg PG_VERSION=$(PG_VER_NUMBER) --build-arg TS_VERSION=$(TS_VERSION) --build-arg PREV_IMAGE=$(PREV_IMAGE) --build-arg PGVECTOR_VERSION=$(PGVECTOR_VERSION) --build-arg PGAI_VERSION=$(PGAI_VERSION) $(TAG) .
touch .build_$(TS_VERSION)_$(PG_VER)

image: .build_$(TS_VERSION)_$(PG_VER)
Expand Down

0 comments on commit 20e456c

Please sign in to comment.