mirror of
https://github.com/dredx/prole.git
synced 2026-09-27 16:04:30 +00:00
- Dockerfile: Resolved interactive tzdata prompts with debconf and fixed Percona package names (percona-pg-stat-monitor18 and percona-postgresql-contrib). - Configuration: Updated prole.cfg with specific namespace (prole-hq0-db0), user (chrisfu), and encrypted secrets. - Installer: Enhanced initialization scripts (init_openbao.sh, init_certmgr.sh) and updated service layers for cluster deployment. - Tests: Added coverage for dependent image collection in installer core. - Version: Bumped prole-db version to 77. Co-authored-by: Junie <junie@jetbrains.com>
148 lines
6.3 KiB
Docker
148 lines
6.3 KiB
Docker
# syntax=docker/dockerfile:1.4
|
|
FROM ubuntu:24.04
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV LANG=C.UTF-8
|
|
ENV PGDATA=/var/lib/postgresql/data
|
|
ENV TZ=Etc/GMT-0
|
|
|
|
RUN set -eux; \
|
|
apt-get update; \
|
|
apt-get install -y --no-install-recommends \
|
|
ca-certificates curl wget gnupg2 lsb-release \
|
|
locales \
|
|
gosu \
|
|
build-essential git openssh-client \
|
|
; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
locale-gen en_US.UTF-8
|
|
|
|
# Configure non-interactive timezone to avoid tzdata prompts
|
|
RUN set -eux; \
|
|
echo "tzdata tzdata/Areas select Etc" | debconf-set-selections; \
|
|
echo "tzdata tzdata/Zones/Etc select GMT-0" | debconf-set-selections; \
|
|
apt-get update; \
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
|
|
echo $TZ > /etc/timezone; \
|
|
dpkg-reconfigure -f noninteractive tzdata
|
|
|
|
RUN set -eux; \
|
|
mkdir -p /root/.ssh; \
|
|
ssh-keyscan github.com >> /root/.ssh/known_hosts
|
|
|
|
# Percona installation
|
|
RUN set -eux; \
|
|
apt-get update; \
|
|
wget -q "https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb"; \
|
|
dpkg -i "percona-release_latest.$(lsb_release -sc)_all.deb"; \
|
|
rm -f "percona-release_latest.$(lsb_release -sc)_all.deb"; \
|
|
apt-get update; \
|
|
percona-release setup ppg-18; \
|
|
apt-get update; \
|
|
apt-get install -y --no-install-recommends \
|
|
percona-postgresql-18 \
|
|
percona-postgresql-server-dev-18 \
|
|
; \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV PATH=/usr/lib/postgresql/18/bin:$PATH
|
|
|
|
RUN set -eux; \
|
|
groupadd -r postgres --gid=999 || true; \
|
|
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres || true; \
|
|
mkdir -p /var/lib/postgresql /var/run/postgresql "$PGDATA" /docker-entrypoint-initdb.d /etc/prole; \
|
|
chown -R postgres:postgres /var/lib/postgresql /var/run/postgresql /docker-entrypoint-initdb.d; \
|
|
chmod 3777 /var/run/postgresql
|
|
|
|
RUN set -eux; \
|
|
apt-get update; \
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|
cmake \
|
|
libssl-dev \
|
|
libgdal-dev \
|
|
libproj-dev \
|
|
libgeos-dev \
|
|
libxml2-dev \
|
|
libjson-c-dev \
|
|
libprotobuf-c-dev \
|
|
protobuf-c-compiler \
|
|
; \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Extension installation
|
|
RUN set -eux; \
|
|
apt-get update; \
|
|
apt-get install -y --no-install-recommends percona-postgresql-18-postgis-3; \
|
|
apt-get install -y --no-install-recommends percona-postgresql-18-pgvector; \
|
|
apt-get install -y --no-install-recommends percona-postgresql-18-pgaudit; \
|
|
apt-get install -y --no-install-recommends percona-postgresql-18-repack; \
|
|
apt-get install -y --no-install-recommends percona-pg-stat-monitor18; \
|
|
apt-get install -y --no-install-recommends percona-pgbadger; \
|
|
apt-get install -y --no-install-recommends \
|
|
percona-postgresql-contrib \
|
|
freetds-dev \
|
|
; \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Build and install tds_fdw
|
|
RUN --mount=type=ssh set -eux; \
|
|
cd /tmp; \
|
|
git clone https://github.com/tds-fdw/tds_fdw.git; \
|
|
cd tds_fdw; \
|
|
make USE_PGXS=1; \
|
|
make USE_PGXS=1 install; \
|
|
cd /; \
|
|
rm -rf /tmp/tds_fdw
|
|
|
|
# Create extension registration script
|
|
RUN set -eux; \
|
|
echo "#!/bin/bash" > /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo "set -e" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo 'psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL' >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS postgis;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS postgis_topology;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS vector;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS pgcrypto;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS pgaudit;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS pg_repack;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS pg_stat_statements;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS pg_buffercache;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS pg_freespacemap;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS pgrowlocks;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS postgres_fdw;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS dblink;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS pg_stat_monitor;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo " CREATE EXTENSION IF NOT EXISTS tds_fdw;" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
echo "EOSQL" >> /docker-entrypoint-initdb.d/20_create_extensions.sh; \
|
|
chmod +x /docker-entrypoint-initdb.d/20_create_extensions.sh
|
|
|
|
# Barman
|
|
COPY requirements.txt /
|
|
RUN set -xe; apt-get update; apt-get install -y --no-install-recommends build-essential python3-dev python3-pip python3-psycopg2 python3-setuptools
|
|
RUN pip3 install --break-system-packages -r /requirements.txt
|
|
RUN apt-get remove -y --purge --autoremove build-essential python3-dev && rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
|
COPY prole-db-entrypoint.sh /usr/local/bin/prole-entrypoint.sh
|
|
COPY 10_pg_tde_openbao.sh /docker-entrypoint-initdb.d/10_pg_tde_openbao.sh
|
|
COPY prole-db-ssh-openbao.sh /usr/local/bin/prole-db-ssh-openbao.sh
|
|
|
|
COPY postgresql/*.conf /etc/postgresql/18/main/
|
|
RUN chown postgres:postgres /etc/postgresql/18/main/*.conf
|
|
|
|
ARG PROLE_USER=prole
|
|
RUN set -eux; \
|
|
if [ -n "$PROLE_USER" ] && [ "$PROLE_USER" != "root" ] && [ "$PROLE_USER" != "postgres" ]; then \
|
|
if ! id -u "$PROLE_USER" >/dev/null 2>&1; then \
|
|
useradd -m -s /bin/bash "$PROLE_USER"; \
|
|
fi; \
|
|
fi
|
|
|
|
RUN set -eux; \
|
|
chmod +x /usr/local/bin/docker-entrypoint.sh /usr/local/bin/prole-entrypoint.sh /usr/local/bin/prole-db-ssh-openbao.sh /docker-entrypoint-initdb.d/10_pg_tde_openbao.sh
|
|
|
|
EXPOSE 5432
|
|
CMD ["postgres"]
|