2026-02-26 11:02:51 +01:00
|
|
|
FROM debian:trixie-slim
|
2026-02-25 15:00:50 +01:00
|
|
|
|
2026-02-26 11:17:57 +01:00
|
|
|
RUN set -eux; \
|
|
|
|
|
groupadd -r postgres --gid=5432; \
|
|
|
|
|
useradd -r -g postgres --uid=5432 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
2026-02-26 10:54:44 +01:00
|
|
|
install --verbose --directory --owner postgres --group postgres --mode 1755 /var/lib/postgresql
|
2026-02-25 15:39:40 +01:00
|
|
|
|
2026-02-26 11:17:57 +01:00
|
|
|
RUN apt-get update; \
|
2026-02-25 15:00:50 +01:00
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
|
openssh-server \
|
|
|
|
|
sudo \
|
2026-02-26 11:17:57 +01:00
|
|
|
; \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
|
|
|
echo "postgres ALL = (ALL) NOPASSWD:ALL" >> /etc/sudoers; \
|
|
|
|
|
echo "X11Forwarding no" >> /etc/ssh/sshd_config; \
|
|
|
|
|
echo "PasswordAuthentication no" >> /etc/ssh/sshd_config; \
|
2026-02-25 15:49:49 +01:00
|
|
|
echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config
|
2026-02-25 15:47:33 +01:00
|
|
|
|
2026-02-26 10:58:18 +01:00
|
|
|
RUN set -eux; \
|
2026-02-26 11:17:57 +01:00
|
|
|
grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
|
|
|
|
|
sed -ri '/\/usr\/share\/locale/d' /etc/dpkg/dpkg.cfg.d/docker; \
|
|
|
|
|
! grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
|
|
|
|
|
apt-get update; \
|
2026-02-26 10:58:18 +01:00
|
|
|
apt-get install -y --no-install-recommends \
|
2026-02-26 11:17:57 +01:00
|
|
|
locales; \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
|
|
|
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen; \
|
|
|
|
|
locale-gen; \
|
2026-02-26 10:58:18 +01:00
|
|
|
locale -a | grep 'en_US.utf8'
|
|
|
|
|
ENV LANG=en_US.utf8
|
2026-02-25 15:00:50 +01:00
|
|
|
|
2026-02-26 11:17:57 +01:00
|
|
|
RUN set -ex; \
|
|
|
|
|
apt-get update; \
|
2026-02-26 10:54:44 +01:00
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
|
gnupg \
|
|
|
|
|
less \
|
2026-02-26 10:58:18 +01:00
|
|
|
xz-utils \
|
|
|
|
|
zstd \
|
2026-02-26 11:17:57 +01:00
|
|
|
; \
|
2026-02-26 10:54:44 +01:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
ENV GOSU_VERSION=1.19
|
2026-02-26 11:17:57 +01:00
|
|
|
RUN set -eux; \
|
|
|
|
|
savedAptMark="$(apt-mark showmanual)"; \
|
|
|
|
|
apt-get update; \
|
2026-02-26 10:54:44 +01:00
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
|
ca-certificates \
|
|
|
|
|
wget \
|
2026-02-26 11:17:57 +01:00
|
|
|
; \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
|
|
|
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
|
|
|
|
|
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${dpkgArch}"; \
|
2026-02-26 10:54:44 +01:00
|
|
|
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${dpkgArch}.asc" &6 \
|
2026-02-26 11:17:57 +01:00
|
|
|
export GNUPGHOME="$(mktemp -d)"; \
|
|
|
|
|
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
|
|
|
|
|
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
|
|
|
|
|
gpgconf --kill all; \
|
|
|
|
|
rm -rf "${GNUPGHOME}" /usr/local/bin/gosu.asc; \
|
|
|
|
|
apt-mark auto '.*' > /dev/null; \
|
|
|
|
|
[ -z "${savedAptMark}" ] || apt-mark manual "${savedAptMark}" > /dev/null; \
|
|
|
|
|
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
|
|
|
|
|
chmod +x /usr/local/bin/gosu; \
|
|
|
|
|
gosu --version; \
|
2026-02-26 10:54:44 +01:00
|
|
|
gosu nobody true
|
|
|
|
|
|
2026-02-26 11:17:57 +01:00
|
|
|
RUN set -ex; \
|
|
|
|
|
key='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8'; \
|
|
|
|
|
export GNUPGHOME="$(mktemp -d)"; \
|
|
|
|
|
mkdir -p /usr/local/share/keyrings/; \
|
|
|
|
|
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "${key}"; \
|
|
|
|
|
gpg --batch --export --armor "${key}" > /usr/local/share/keyrings/postgres.gpg.asc; \
|
|
|
|
|
gpgconf --kill all; \
|
2026-02-26 10:54:44 +01:00
|
|
|
rm -rf "${GNUPGHOME}"
|
|
|
|
|
|
|
|
|
|
ENV PG_MAJOR=15
|
|
|
|
|
ENV PATH=$PATH:/usr/lib/postgresql/$PG_MAJOR/bin
|
|
|
|
|
ENV PG_VERSION=15.16-1.pgdg13+1
|
|
|
|
|
ENV PGDATA=/var/lib/postgresql/data
|
|
|
|
|
|
2026-02-26 11:17:57 +01:00
|
|
|
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql; \
|
|
|
|
|
install --verbose --directory --owner postgres --group postgres --mode 3755 /var/lib/postgresql; \
|
2026-02-26 11:00:20 +01:00
|
|
|
install --verbose --directory --owner postgres --group postgres --mode 1700 "${PGDATA}"
|
2026-02-26 10:54:44 +01:00
|
|
|
|
2026-02-26 11:17:57 +01:00
|
|
|
RUN set -ex; \
|
|
|
|
|
dpkgArch="$(dpkg --print-architecture)"; \
|
|
|
|
|
aptRepo="[ signed-by=/usr/local/share/keyrings/postgres.gpg.asc ] http://apt.postgresql.org/pub/repos/apt trixie-pgdg main ${PG_MAJOR}"; \
|
|
|
|
|
echo "deb ${aptRepo}" > /etc/apt/sources.list.d/pgdg.list; \
|
|
|
|
|
apt-get update; \
|
2026-02-26 10:54:44 +01:00
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
|
postgresql-common \
|
2026-02-26 11:17:57 +01:00
|
|
|
; \
|
|
|
|
|
sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf; \
|
2026-02-26 10:54:44 +01:00
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
|
"postgresql-${PG_MAJOR}=${PG_VERSION}" \
|
|
|
|
|
"postgresql-${PG_MAJOR}-pgpool2" \
|
2026-02-26 11:17:57 +01:00
|
|
|
; \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*; \
|
2026-02-26 10:54:44 +01:00
|
|
|
postgres --version
|
|
|
|
|
|
2026-02-26 11:17:57 +01:00
|
|
|
RUN set -eux; \
|
|
|
|
|
dpkg-divert --add --rename --divert "/usr/share/postgresql/postgresql.conf.sample.dpkg" "/usr/share/postgresql/${PG_MAJOR}/postgresql.conf.sample"; \
|
|
|
|
|
cp -v /usr/share/postgresql/postgresql.conf.sample.dpkg /usr/share/postgresql/postgresql.conf.sample; \
|
|
|
|
|
ln -sv ../postgresql.conf.sample "/usr/share/postgresql/${PG_MAJOR}/"; \
|
|
|
|
|
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
2026-02-26 10:54:44 +01:00
|
|
|
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
|
|
|
|
|
|
|
|
|
VOLUME /var/lib/postgresql/data
|
|
|
|
|
|
|
|
|
|
COPY --chown=postgres:postgres postgres /var/lib/postgresql/
|
2026-02-25 15:00:50 +01:00
|
|
|
COPY --chmod=755 entrypoint.sh /usr/local/bin/
|
|
|
|
|
|
|
|
|
|
ENTRYPOINT ["entrypoint.sh"]
|