d28840cc by Adam Heath

Postgresql recipe.

1 parent d3ef44bc
FROM debian:stretch-slim
ARG POSTGRESQL_EXTRA_PACKAGES
COPY files/ /tmp/files
RUN /tmp/files/configure
ENTRYPOINT ["/sbin/entrypoint"]
CMD ["pg_ctlcluster", "9.6", "main", "start", "--foreground"]
#!/bin/sh
set -e
mkdir /usr/share/man/man1 /usr/share/man/man7
cp /tmp/files/no-suggests-recommends.conf /etc/apt/apt.conf.d/no-suggests-recommends
apt-get update
apt-get install -y postgresql-9.6 \
$POSTGRESQL_EXTRA_PACKAGES \
&& true
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
mkdir /var/lib/container
tar -cC /var/lib/postgresql/ . | gzip -9v > /var/lib/container/var_lib_postgresql.tar.gz
rm -rf /var/lib/postgresql
mkdir /var/lib/postgresql
cp -a /tmp/files/entrypoint /sbin
rm -rf /tmp/files
#!/bin/bash
declare -a found_errors
set -ex
if [[ $(find /var/lib/postgresql -maxdepth 1 -mindepth 1|wc -l) = 0 ]]; then
zcat /var/lib/container/var_lib_postgresql.tar.gz | tar xf - -C /var/lib/postgresql
fi
postgres_home="$(getent passwd postgres | cut -f 6 -d :)"
if [[ $GID ]]; then
old_gid=$(getent group postgres | cut -f 3 -d :)
groupmod -g $GID postgres
find "$postgres_home" /etc/postgresql /var/run/postgresql -gid $old_gid -print0 | xargs -0r chgrp postgres
fi
if [[ $UID ]]; then
old_uid=$(getent passwd postgres | cut -f 3 -d :)
usermod -u $UID postgres
find /etc/postgresql /var/run/postgresql -uid $old_uid -print0 | xargs -0r chown postgres
fi
exec "$@"
APT::Install-Suggests false;
APT::Install-Recommends false;