Postgresql graph data science
494
This PostgreSQL image (initially based on this project) includes the following extensions to enable multi-modal behaviour:
docker run -it -e POSTGRES_PASSWORD=password -p 5434:5432 --mount source=postgres_data,destination=/home/postgres/pgdata/data petescarth/postgres-datascience
See Apache Age Docs for more details.
CREATE EXTENSION age;
SET search_path = ag_catalog, "$user", public;
GRANT USAGE ON SCHEMA ag_catalog TO db_user;
LOAD 'age';
# Use ARGs at the top for default values and reuse throughout the Dockerfile
ARG PG_VERSION=14
ARG APACHE_AGE_VERSION=1.5.0
ARG TIMESCALE_VERSION=2.15
# Use Docker image containing TimescaleDB, Patroni to be used by developers and Kubernetes.
# https://github.com/timescale/timescaledb-docker-ha
FROM timescale/timescaledb-ha:pg${PG_VERSION}-ts${TIMESCALE_VERSION}
# Pass ARGs after FROM so they are accessible in the build stage
ARG PG_VERSION
ARG APACHE_AGE_VERSION
ARG TIMESCALE_VERSION
# Switch to root user to install apache age and other dependencies
USER root
# Install system dependencies and cleanup in a single RUN command to reduce image size
RUN apt-get update && apt-get install -y \
python3.11 \
python3-pip \
python3-setuptools \
python3-wheel \
htop \
nano \
gnupg \
coreutils \
sudo \
openssl \
git \
curl \
lsb-release \
build-essential \
libreadline-dev \
zlib1g-dev \
flex \
bison \
make \
software-properties-common \
gpg-agent \
postgresql-server-dev-${PG_VERSION} && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Download and install Apache AGE https://github.com/apache/age/
RUN curl -LJO "https://github.com/apache/age/releases/download/PG${PG_VERSION}%2Fv${APACHE_AGE_VERSION}-rc0/apache-age-${APACHE_AGE_VERSION}-src.tar.gz" && \
tar -xvzf apache-age-${APACHE_AGE_VERSION}-src.tar.gz && \
cd apache-age-${APACHE_AGE_VERSION} && \
make PG_CONFIG=/usr/lib/postgresql/${PG_VERSION}/bin/pg_config install && \
cd .. && rm -rf apache-age-${APACHE_AGE_VERSION}-src.tar.gz apache-age-${APACHE_AGE_VERSION} && \
ln -s /usr/lib/postgresql/${PG_VERSION}/lib/age.so /usr/lib/postgresql/${PG_VERSION}/lib/plugins/age.so
# Install PostgresML with necessary sources and keys in one RUN layer
RUN echo "deb [trusted=yes] https://apt.postgresml.org $(lsb_release -cs) main" > /etc/apt/sources.list.d/postgresml.list && \
echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg && \
apt-get update && \
apt-get install -y postgresql-pgml-${PG_VERSION} \
timescaledb-toolkit-postgresql-${PG_VERSION} && \
rm -rf /var/lib/apt/lists/*
# Install the PostgresML extension python dependencies
# From https://github.com/postgresml/postgresml/tree/master/pgml-extension
RUN curl -LJO https://raw.githubusercontent.com/postgresml/postgresml/master/pgml-extension/requirements.txt
RUN pip3 install --no-cache-dir --default-timeout=120 -r requirements.txt
# Add in the pgml extension to the postgresql.conf.sample shared_preload_libraries
# Method from: https://github.com/timescale/timescaledb-docker-ha/blob/master/Dockerfile
# Also change timescaledb.license from open-source Apache-2 License to Timescale Licence
# See https://github.com/timescale/timescaledb/blob/main/tsl/LICENSE-TIMESCALE
RUN for file in $(find /usr/share/postgresql -name 'postgresql.conf.sample'); do \
sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'pgml,pg_stat_statements,\2'/;s/,'/'/" $file \
&& echo "timescaledb.license = timescale" >> $file; \
done
# Write pgml.control content directly using echo
RUN echo "comment = 'pgml: Created by the PostgresML team'\n\
default_version = '2.8.2'\n\
module_pathname = '\$libdir\/pgml'\n\
relocatable = false\n\
superuser = true\n\
schema = 'pgml'" > /usr/share/postgresql/${PG_VERSION}/extension/pgml.control
# Back to postgres user
USER postgres
Content type
Image
Digest
sha256:58278be08…
Size
4.9 GB
Last updated
over 2 years ago
docker pull petescarth/postgres-datascience