Skip to content

Commit

Permalink
WIP: install pgai in stages
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesGuthrie committed Jan 21, 2025
1 parent 64f8720 commit 5614af2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
37 changes: 22 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ RUN set -ex; \
apk del .vector-deps;

# install pgai only on pg16+ and not on 32 bit arm
ARG PGAI_VERSION
ARG PGAI_VERSIONS
ARG PG_MAJOR_VERSION
ARG TARGETARCH
RUN set -ex; \
if [ "$PG_MAJOR_VERSION" -ge 16 ] && [ "$TARGETARCH" != "arm" ]; then \
apk update; \
apk add --no-cache libarrow libparquet; \
apk add --no-cache --virtual .pgai-deps \
git \
build-base \
Expand All @@ -74,22 +75,28 @@ RUN set -ex; \
python3-dev \
apache-arrow-dev \
py3-pip; \
git clone --branch ${PGAI_VERSION} https://github.com/timescale/pgai.git /build/pgai; \
cd /build/pgai; \
# note: this is a hack. pyarrow will be built from source, so must be pinned to this arrow version \
echo pyarrow==$(pkg-config --modversion arrow) >> ./projects/extension/requirements.txt; \
if [ "$TARGETARCH" == "386" ]; then \
# note: pinned because pandas 2.2.0-2.2.3 on i386 is affected by https://github.com/pandas-dev/pandas/issues/59905 \
echo pandas==2.1.4 >> ./projects/extension/requirements.txt; \
# note: no prebuilt binaries for pillow on i386 \
apk add --no-cache --virtual .pgai-deps-386 \
jpeg-dev \
zlib-dev; \
fi; \
PG_BIN="/usr/local/bin" PG_MAJOR=${PG_MAJOR_VERSION} ./projects/extension/build.py install; \
for PGAI_VERSION in ${PGAI_VERSIONS}; do \
git clone --branch ${PGAI_VERSION} https://github.com/timescale/pgai.git /build/pgai-${PGAI_VERSION}; \
cd /build/pgai-${PGAI_VERSION}; \
echo "pyarrow==$(pkg-config --modversion arrow)" > constraints.txt; \
export PIP_CONSTRAINT=$(pwd)/constraints.txt; \
if [ "$TARGETARCH" == "386" ]; then \
# note: pinned because pandas 2.2.0-2.2.3 on i386 is affected by https://github.com/pandas-dev/pandas/issues/59905 \
echo pandas==2.1.4 >> constraints.txt; \
# note: no prebuilt binaries for pillow on i386 \
apk add --no-cache --virtual .pgai-deps-386 \
jpeg-dev \
zlib-dev; \
fi; \
if [ "${PGAI_VERSION}" != "extension-0.4.0" ]; then \
cd projects/extension; \
fi; \
PG_BIN="/usr/local/bin" PG_MAJOR=${PG_MAJOR_VERSION} ./build.py install-py; \
PG_BIN="/usr/local/bin" PG_MAJOR=${PG_MAJOR_VERSION} ./build.py install-sql; \
done; \
if [ "$TARGETARCH" == "386" ]; then apk del .pgai-deps-386; fi; \
apk del .pgai-deps; \
fi
fi

COPY docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d/
COPY --from=tools /go/bin/* /usr/local/bin/
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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.2
PGAI_VERSION=extension-0.6.0
PGAI_VERSIONS="extension-0.4.0 extension-0.4.1 extension-0.5.0 extension-0.6.0 extension-0.7.0"

COMMON_BUILD_ARGS= --build-arg TS_VERSION=$(TS_VERSION) \
--build-arg PREV_IMAGE=$(PREV_IMAGE) \
Expand All @@ -37,7 +37,7 @@ COMMON_BUILD_ARGS= --build-arg TS_VERSION=$(TS_VERSION) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg CLANG_VERSION=$(CLANG_VERSION) \
--build-arg PGVECTOR_VERSION=$(PGVECTOR_VERSION) \
--build-arg PGAI_VERSION=$(PGAI_VERSION)
--build-arg PGAI_VERSIONS=$(PGAI_VERSIONS)

default: image

Expand Down Expand Up @@ -70,7 +70,7 @@ default: image
touch .build_$(TS_VERSION)_$(PG_VER)_oss

.build_$(TS_VERSION)_$(PG_VER): Dockerfile
docker build $(COMMON_BUILD_ARGS) $(TAG) .
docker build --progress plain $(COMMON_BUILD_ARGS) $(TAG) .
touch .build_$(TS_VERSION)_$(PG_VER)

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

0 comments on commit 5614af2

Please sign in to comment.