d28840cc by Adam Heath

Postgresql recipe.

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