Skip to content

Commit

Permalink
Debug docker
Browse files Browse the repository at this point in the history
  • Loading branch information
svenklemm committed Feb 11, 2025
1 parent a6b0d22 commit 536dc0a
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 54 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches: [ release_docker, dev-build ]
pull_request:
paths: .github/workflows/docker-image.yml
workflow_dispatch:
inputs:
version:
Expand All @@ -25,7 +24,7 @@ jobs:
timescaledb:

name: PG${{ matrix.pg }}${{ matrix.oss }}
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -54,6 +53,7 @@ jobs:
if [ "${{ github.event_name }}" == "pull_request" ]
then
export ORG=timescaledev
export BETA=1
fi
if [ "${{ github.event.inputs.no_tag_latest }}" == "true" ]
then
Expand Down
112 changes: 61 additions & 51 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,69 +36,79 @@ LABEL maintainer="Timescale https://www.timescale.com"


ARG PG_VERSION
ARG PG_MAJOR_VERSION
ARG ALPINE_VERSION
RUN set -ex; \
echo "https://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community/" >> /etc/apk/repositories; \
apk update; \
apk add --no-cache \
postgresql${PG_VERSION}-plpython3;
if [ "$PG_MAJOR_VERSION" -ge 16 ] ; then \
apk add --no-cache postgresql${PG_VERSION}-plpython3; \
fi

ARG PGVECTOR_VERSION
ARG PG_VERSION
ARG CLANG_VERSION
RUN set -ex; \
apk update; \
apk add --no-cache --virtual .vector-deps \
postgresql${PG_VERSION}-dev \
git \
build-base \
clang${CLANG_VERSION} \
llvm${CLANG_VERSION}-dev \
llvm${CLANG_VERSION}; \
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+ and not on 32 bit arm
ARG PGAI_VERSION
ARG PG_MAJOR_VERSION
ARG TARGETARCH
RUN set -ex; \
if [ "$PG_MAJOR_VERSION" -ge 16 ] && [ "$TARGETARCH" != "arm" ]; then \
apk update; \
# install shared libraries needed at runtime
apk add libarrow libparquet geos; \
# install required dependencies for building pyarrow from source
apk add --no-cache --virtual .pgai-deps \
apk update; \
if [ "$PG_MAJOR_VERSION" -ge 17 ] ; then \
apk add --no-cache postgresql-pgvector; \
else \
apk add --no-cache --virtual .vector-deps \
postgresql${PG_VERSION}-dev \
git \
build-base \
cargo \
cmake \
python3-dev \
py3-pip \
apache-arrow-dev \
geos-dev; \
# using uv reduces space required for pgai's dependencies \
python3 -m pip install uv --break-system-packages; \
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)" > 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; \
export PIP_CONSTRAINT=$(pwd)/constraints.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; \
if [ "$TARGETARCH" == "386" ]; then apk del .pgai-deps-386; fi; \
apk del .pgai-deps; \
clang${CLANG_VERSION} \
llvm${CLANG_VERSION}-dev \
llvm${CLANG_VERSION}; \
git clone --branch ${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git /build/pgvector; \
cd /build/pgvector; \
make; \
make install; \
apk del .vector-deps; \
fi

# # install pgai only on pg16+ and not on 32 bit arm
# ARG PGAI_VERSION
# ARG PG_MAJOR_VERSION
# ARG TARGETARCH
# RUN set -ex; \
# if [ "$PG_MAJOR_VERSION" -ge 16 ] && [ "$TARGETARCH" != "arm" ]; then \
# apk update; \
# # install shared libraries needed at runtime
# apk add libarrow libparquet geos py3-pandas; \
# # install required dependencies for building pyarrow from source
# apk add --no-cache --virtual .pgai-deps \
# git \
# build-base \
# cargo \
# cmake \
# python3-dev \
# py3-pip \
# apache-arrow-dev \
# geos-dev; \
# if [ "$(pip --version | awk '{print $2; exit}')" \< "23.0.1" ]; then \
# python3 -m pip install --upgrade pip==23.0.1; \
# fi; \
# 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)" > 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; \
# export PIP_CONSTRAINT=$(pwd)/constraints.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; \
# if [ "$TARGETARCH" == "386" ]; then apk del .pgai-deps-386; fi; \
# 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/
Expand Down
5 changes: 4 additions & 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=pg16
PG_VER=pg17
PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-)
PG_MAJOR_VERSION=$(shell echo $(PG_VER_NUMBER) | cut -d. -f1)
ifeq ($(shell test $(PG_MAJOR_VERSION) -ge 16; echo $$?),0)
Expand Down Expand Up @@ -44,6 +44,8 @@ default: image
.multi_$(TS_VERSION)_$(PG_VER)_oss: Dockerfile
test -n "$(TS_VERSION)" # TS_VERSION
test -n "$(PREV_TS_VERSION)" # PREV_TS_VERSION
test -n "$(PREV_IMAGE)" # PREV_IMAGE
test -n "$(ALPINE_VERSION)" # ALPINE_VERSION
docker buildx create --platform $(PLATFORM) --name multibuild --use
docker buildx inspect multibuild --bootstrap
docker buildx build --platform $(PLATFORM) \
Expand All @@ -57,6 +59,7 @@ default: image
test -n "$(TS_VERSION)" # TS_VERSION
test -n "$(PREV_TS_VERSION)" # PREV_TS_VERSION
test -n "$(PREV_IMAGE)" # PREV_IMAGE
test -n "$(ALPINE_VERSION)" # ALPINE_VERSION
docker buildx create --platform $(PLATFORM) --name multibuild --use
docker buildx inspect multibuild --bootstrap
docker buildx build --platform $(PLATFORM) \
Expand Down

0 comments on commit 536dc0a

Please sign in to comment.