Skip to content

Commit

Permalink
Install Promscale Extension using compiled package
Browse files Browse the repository at this point in the history
  • Loading branch information
feikesteenbergen committed Jul 12, 2022
1 parent ad35404 commit f24996c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,10 @@ ENV RUSTC_WRAPPER=/build/bin/sccache
ENV SCCACHE_BUCKET=timescaledb-docker-ha-sccache

ARG TIMESCALE_PROMSCALE_EXTENSIONS=
ARG TIMESCALE_PROMSCALE_REPO=github.com/timescale/promscale_extension
# build and install the promscale_extension extension
RUN --mount=type=secret,uid=1000,id=AWS_ACCESS_KEY_ID --mount=type=secret,uid=1000,id=AWS_SECRET_ACCESS_KEY \
if [ ! -z "${TIMESCALE_PROMSCALE_EXTENSIONS}" -a -z "${OSS_ONLY}" ]; then \
[ -f "/run/secrets/AWS_ACCESS_KEY_ID" ] && export AWS_ACCESS_KEY_ID="$(cat /run/secrets/AWS_ACCESS_KEY_ID)" ; \
[ -f "/run/secrets/AWS_SECRET_ACCESS_KEY" ] && export AWS_SECRET_ACCESS_KEY="$(cat /run/secrets/AWS_SECRET_ACCESS_KEY)" ; \
RUN if [ ! -z "${TIMESCALE_PROMSCALE_EXTENSIONS}" -a -z "${OSS_ONLY}" ]; then \
set -e \
&& git clone https://${TIMESCALE_PROMSCALE_REPO} /build/promscale_extension \
&& mkdir /build/promscale_extension \
&& cd /build/promscale_extension \
&& for pg in ${PG_VERSIONS}; do \
/build/scripts/install_promscale.sh ${pg} ${TIMESCALE_PROMSCALE_EXTENSIONS} || exit 1 ; \
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ POSTGIS_VERSIONS?="3"
PG_AUTH_MON?=v1.0
PG_STAT_MONITOR?=1.0.0-rc.1
PG_LOGERRORS?=3c55887b
TIMESCALE_PROMSCALE_EXTENSIONS?=0.3.2 0.5.0 0.5.1 0.5.2
TIMESCALE_PROMSCALE_REPO?=github.com/timescale/promscale_extension
TIMESCALE_PROMSCALE_EXTENSIONS?=0.5.0 0.5.1 0.5.2
TIMESCALEDB_TOOLKIT_EXTENSIONS?=1.6.0 1.7.0 1.8.0
TIMESCALE_TSDB_ADMIN?=
TIMESCALE_HOT_FORGE?=
Expand Down Expand Up @@ -77,7 +76,6 @@ DOCKER_BUILD_COMMAND=docker build --progress=plain \
--build-arg TIMESCALE_HOT_FORGE="$(TIMESCALE_HOT_FORGE)" \
--build-arg TIMESCALE_OOM_GUARD="$(TIMESCALE_OOM_GUARD)" \
--build-arg TIMESCALE_PROMSCALE_EXTENSIONS="$(TIMESCALE_PROMSCALE_EXTENSIONS)" \
--build-arg TIMESCALE_PROMSCALE_REPO="$(TIMESCALE_PROMSCALE_REPO)" \
--build-arg TIMESCALE_TSDB_ADMIN="$(TIMESCALE_TSDB_ADMIN)" \
--build-arg TIMESCALEDB_TOOLKIT_EXTENSIONS="$(TIMESCALEDB_TOOLKIT_EXTENSIONS)" \
--build-arg TIMESCALE_STATIC_PRIMARY="$(TIMESCALE_STATIC_PRIMARY)" \
Expand Down
25 changes: 21 additions & 4 deletions build_scripts/install_promscale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,25 @@ export PATH="/usr/lib/postgresql/${PGVERSION}/bin:${PATH}"
mkdir -p /home/postgres/.pgx

for PROMSCALE_VERSION in "$@"; do
DEBVERSION="$(apt info -a promscale-extension-postgresql-${PGVERSION} | awk '/Version:/ {print $2}' | grep "${PROMSCALE_VERSION}" | head -n 1)"
apt-get download promscale-extension-postgresql-${PGVERSION}=${DEBVERSION}
dpkg --install --admindir /tmp/dpkg --force-depends --force-not-root --force-overwrite promscale-extension-postgresql-${PGVERSION}*${DEBVERSION}*.deb
done
git clean -e target -f -x
git reset HEAD --hard
git checkout "${PROMSCALE_VERSION}"

MAJOR_MINOR="$(awk '/^version/ {print $3}' ./Cargo.toml | tr -d "\"" | cut -d. -f1,2)"
MAJOR="$(echo "${MAJOR_MINOR}" | cut -d. -f1)"
MINOR="$(echo "${MAJOR_MINOR}" | cut -d. -f2)"

if [ "${MAJOR}" -le 0 ] && [ "${MINOR}" -le 3 ]; then
cargo install cargo-pgx --version '^0.2'
else
cargo install cargo-pgx --git https://github.com/timescale/pgx --branch promscale-staging
fi
cargo pgx init "--pg${PGVERSION}" "/usr/lib/postgresql/${PGVERSION}/bin/pg_config"
if [ "${MAJOR}" -le 0 ] && [ "${MINOR}" -le 3 ]; then
PG_VER=pg${PGVERSION} make install || exit 1;
elif [ "${PROMSCALE_VERSION}" = "0.5.1" ]; then
make package && cp -v --recursive "./target/release/promscale-pg${PGVERSION}/"* / || exit 1
else
(make package && make install) || exit 1;
fi
done

0 comments on commit f24996c

Please sign in to comment.