sraoss / pg_ivm

IVM (Incremental View Maintenance) implementation as a PostgreSQL extension
Other
994 stars 27 forks source link

installation inside a pg docker container #86

Open abhijeetbhagat opened 7 months ago

abhijeetbhagat commented 7 months ago

how do i install this inside a docker container running pg?

koureasstavros commented 7 months ago

Lets assume you have a folder PostgeSQL and inside you have the following Dockerfile, then in the same level with Dockerfile you should have one folder called resources and inside that folder you have the necessary pg extensions like pg_ivm-1.7, inside this folder you should have all the extension files whitch also containing .sql and Makefile

# Debian GNU/Linux
FROM postgres:15.4

RUN localedef -i en_GB -c -f UTF-8 -A /usr/share/locale/locale.alias en_GB.UTF-8
ENV LANG en_GB.utf8

# Update System (update registries)
RUN apt-get update

WORKDIR /

# Deploy DeveloperTools #should follow postgresql version (otherwise it will throw error on package install)
RUN apt-get -y install postgresql-server-dev-15 #installs also repective python version based on postgresql version 

# Deploy Make
RUN apt-get -y install build-essential

ADD /resources/ /resources/

# Deploy PostgreSQL pg_cron (not exist as online repo)
WORKDIR /resources/pg_ivm-1.7

RUN make clean
RUN make
RUN make install

WORKDIR /
Saghen commented 1 week ago

I built without a resources folder and without including build tools in the final output by using a multi-stage build (also works with bitnami/postgresql:15.9.0)

FROM postgres:15.9 AS builder

RUN apt-get update && apt-get -y install git postgresql-server-dev-15 build-essential && rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/sraoss/pg_ivm
WORKDIR /pg_ivm

RUN git checkout v1.9
RUN make
RUN make DESTDIR=/pg_ivm/output install

FROM postgres:15.9
COPY --from=builder /pg_ivm/output /