103 lines
3.6 KiB
Docker
103 lines
3.6 KiB
Docker
FROM danielberteaud/alma:9.24.3-1 AS pgvectors
|
|
|
|
ARG PG_VERSION=15 \
|
|
PGVECTORS_VERSION=0.2.1
|
|
|
|
WORKDIR /tmp
|
|
RUN set -eux &&\
|
|
dnf update -y &&\
|
|
rpm -i https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm &&\
|
|
dnf -y module disable postgresql &&\
|
|
dnf -y install \
|
|
postgresql${PG_VERSION}-devel \
|
|
postgresql${PG_VERSION}-server \
|
|
openssl-devel \
|
|
gcc \
|
|
pkg-config \
|
|
bison \
|
|
libxml2-devel \
|
|
libxslt-devel \
|
|
clang \
|
|
git \
|
|
&&\
|
|
curl -sSf https://sh.rustup.rs | sh -s -- -y &&\
|
|
export PATH=${HOME}/.cargo/bin:/usr/pgsql-${PG_VERSION}/bin/:${PATH} &&\
|
|
git clone --branch=v${PGVECTORS_VERSION} --depth=1 https://github.com/tensorchord/pgvecto.rs.git &&\
|
|
cd pgvecto.rs &&\
|
|
sed -i "s/@CARGO_VERSION@/${PGVECTORS_VERSION}/g" ./vectors.control &&\
|
|
cargo install cargo-pgrx --version $(grep '^pgrx ' Cargo.toml | awk -F'\"' '{print $2}') &&\
|
|
cargo pgrx init --pg${PG_VERSION}=/usr/pgsql-${PG_VERSION}/bin/pg_config &&\
|
|
cargo pgrx install --no-default-features --features "pg${PG_VERSION}" --release &&\
|
|
cp sql/install/vectors--${PGVECTORS_VERSION}.sql /usr/pgsql-${PG_VERSION}/share/extension/ &&\
|
|
cp sql/upgrade/*.sql /usr/pgsql-${PG_VERSION}/share/extension/
|
|
|
|
|
|
FROM danielberteaud/alma:9.24.3-1
|
|
MAINTAINER Daniel Berteaud <dbd@ehtrace.com>
|
|
|
|
ARG PG_VERSION
|
|
|
|
ENV PATH=/usr/pgsql-${PG_VERSION}/bin:${PATH} \
|
|
PGDATA=/data/db/${PG_VERSION} \
|
|
PG_USER=postgres \
|
|
PG_CONFFILE=postgresql.conf \
|
|
PG_CONF_listen_addresses="'0.0.0.0'" \
|
|
PG_CONF_timezone="'Europe/Paris'" \
|
|
PG_CONF_log_timezone="'Europe/Paris'" \
|
|
PG_CONF_log_line_prefix="'[%l-1] user=%u,db=%d,app=%a,client=%h '" \
|
|
PG_CONF_shared_buffers=25% \
|
|
PG_CONF_maintenance_work_mem=5% \
|
|
PG_CONF_work_mem=1% \
|
|
PG_CONF_wal_compression=zstd \
|
|
PG_CONF_log_min_duration_statement=2000 \
|
|
PG_CONF_log_destination=stderr \
|
|
PG_CONF_log_directory="'/proc/1/fd/'" \
|
|
PG_CONF_log_filename=1 \
|
|
PGHOST=/run/postgresql \
|
|
PGBACKREST_PG1_PATH=/data/db/${PG_VERSION} \
|
|
PGBACKREST_LOCK_PATH=/dev/shm \
|
|
PGBACKREST_COMPRESS_TYPE=zst \
|
|
PGBACKREST_START_FAST=y \
|
|
PGBACKREST_REPO1_BLOCK=y \
|
|
PGBACKREST_REPO1_BUNDLE=y \
|
|
PGBACKREST_REPO1_SFTP_PRIVATE_KEY_FILE=/data/ssh/id_ed25519 \
|
|
PGBACKREST_SPOOL_PATH=/data/spool \
|
|
PGBACKREST_ARCHIVE_ASYNC=y \
|
|
PGBACKREST_ARCHIVE_PUSH_QUEUE_MAX=5GiB \
|
|
PGBACKREST_LOG_PATH=/data/log \
|
|
PGBACKREST_LOG_LEVEL_CONSOLE=detail \
|
|
PGBACKREST_REPO1_RETENTION_HISTORY=365
|
|
|
|
RUN set -eux &&\
|
|
dnf update -y &&\
|
|
rpm -i https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm &&\
|
|
dnf -y module disable postgresql &&\
|
|
dnf -y install \
|
|
glibc-langpack-en \
|
|
glibc-langpack-fr \
|
|
postgresql${PG_VERSION}-server \
|
|
postgresql${PG_VERSION}-contrib \
|
|
postgresql_anonymizer_${PG_VERSION} \
|
|
# timescaledb_${PG_VERSION} \
|
|
libssh2 \
|
|
openssh-clients \
|
|
pgbackrest \
|
|
screen \
|
|
&&\
|
|
mkdir -p /data/db/${PG_VERSION} &&\
|
|
mkdir -p /data/ssh &&\
|
|
mkdir -p /data/spool &&\
|
|
mkdir -p /data/log &&\
|
|
mkdir -p /run/postgresql &&\
|
|
chmod 750 /data/db/${PG_VERSION} /data/ssh /data/spool /data/log &&\
|
|
chown -R postgres:postgres /data /run/postgresql &&\
|
|
rm -rf /var/cache/yum/* /var/log/yum/* /var/lib/dnf/history*
|
|
|
|
COPY --from=pgvectors /usr/pgsql-${PG_VERSION}/share/extension/vectors* /usr/pgsql-${PG_VERSION}/share/extension/
|
|
COPY --from=pgvectors /usr/pgsql-${PG_VERSION}/lib/vectors.so /usr/pgsql-${PG_VERSION}/lib/vectors.so
|
|
COPY root/ /
|
|
|
|
EXPOSE 5432
|
|
USER postgres
|
|
CMD ["postgres"]
|