Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: install pgai in stages #293

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading