diff --git a/Dockerfile b/Dockerfile index a334ff2..3176208 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,22 +10,23 @@ RUN go install github.com/timescale/timescaledb-parallel-copy/cmd/timescaledb-pa FROM postgres:$PG_MAJOR-bookworm SHELL ["/bin/bash", "-c"] +ARG TS_REF=2.13.0 ARG PGVECTOR_REF=v0.5.1 ARG PGVECTOR_HASH=e630efd195c563496c3550abb1817303586ee46d1 RUN apt-get update && \ apt-mark hold locales && \ - apt-get install -y --no-install-recommends build-essential ca-certificates git cmake postgresql-server-dev-$PG_MAJOR + apt-get install -y --no-install-recommends build-essential ca-certificates git cmake libkrb5-dev postgresql-server-dev-$PG_MAJOR RUN git clone --branch $PGVECTOR_REF --depth 1 https://github.com/pgvector/pgvector.git /tmp/pgvector/ WORKDIR /tmp/pgvector/ RUN make && make install COPY docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d/ -COPY --from=tools /go/bin/* /usr/local/bin/ +COPY --from=timebuild /go/bin/* /usr/local/bin/ RUN git clone --branch $TS_REF https://github.com/timescale/timescaledb /tmp/timescaledb WORKDIR /tmp/timescaledb RUN ./bootstrap -DCMAKE_BUILD_TYPE=RelWithDebInfo -DREGRESS_CHECKS=OFF -DTAP_CHECKS=OFF -DGENERATE_DOWNGRADE_SCRIPT=ON -DWARNINGS_AS_ERRORS=OFF -DPROJECT_INSTALL_METHOD="docker" - +RUN cd build && make && make install WORKDIR / diff --git a/docker-entrypoint-initdb.d/002-install-pgvector.sh b/docker-entrypoint-initdb.d/002-install-pgvector.sh new file mode 100644 index 0000000..491999b --- /dev/null +++ b/docker-entrypoint-initdb.d/002-install-pgvector.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +create_sql=`mktemp` + +# Checks to support bitnami image with same scripts so they stay in sync +if [ ! -z "${BITNAMI_APP_NAME:-}" ]; then + if [ -z "${POSTGRES_USER:-}" ]; then + POSTGRES_USER=${POSTGRESQL_USERNAME} + fi + + if [ -z "${POSTGRES_DB:-}" ]; then + POSTGRES_DB=${POSTGRESQL_DATABASE} + fi + + if [ -z "${PGDATA:-}" ]; then + PGDATA=${POSTGRESQL_DATA_DIR} + fi +fi + +if [ -z "${POSTGRESQL_CONF_DIR:-}" ]; then + POSTGRESQL_CONF_DIR=${PGDATA} +fi + +cat <${create_sql} +CREATE EXTENSION IF NOT EXISTS pgvector CASCADE; +EOF + +if [ -z "${POSTGRESQL_PASSWORD:-}" ]; then + POSTGRESQL_PASSWORD=${POSTGRES_PASSWORD} +fi +export PGPASSWORD="$POSTGRESQL_PASSWORD" + +# create extension timescaledb in initial databases +psql -U "${POSTGRES_USER}" postgres -f ${create_sql} +psql -U "${POSTGRES_USER}" template1 -f ${create_sql} + +if [ "${POSTGRES_DB:-postgres}" != 'postgres' ]; then + psql -U "${POSTGRES_USER}" "${POSTGRES_DB}" -f ${create_sql} +fi +