Skip to content

Commit 0f910e3

Browse files
committed
Add 9.6~beta1-1.pgdg80+1
1 parent 04b1d36 commit 0f910e3

File tree

3 files changed

+159
-0
lines changed

3 files changed

+159
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: bash
22
services: docker
33

44
env:
5+
- VERSION=9.6
56
- VERSION=9.5
67
- VERSION=9.4
78
- VERSION=9.3

9.6/Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# vim:set ft=dockerfile:
2+
FROM debian:jessie
3+
4+
# explicitly set user/group IDs
5+
RUN groupadd -r postgres --gid=999 && useradd -r -g postgres --uid=999 postgres
6+
7+
# grab gosu for easy step-down from root
8+
ENV GOSU_VERSION 1.7
9+
RUN set -x \
10+
&& apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \
11+
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
12+
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
13+
&& export GNUPGHOME="$(mktemp -d)" \
14+
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
15+
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
16+
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
17+
&& chmod +x /usr/local/bin/gosu \
18+
&& gosu nobody true \
19+
&& apt-get purge -y --auto-remove ca-certificates wget
20+
21+
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
22+
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
23+
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
24+
ENV LANG en_US.utf8
25+
26+
RUN mkdir /docker-entrypoint-initdb.d
27+
28+
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
29+
30+
ENV PG_MAJOR 9.6
31+
ENV PG_VERSION 9.6~beta1-1.pgdg80+1
32+
33+
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
34+
35+
RUN apt-get update \
36+
&& apt-get install -y postgresql-common \
37+
&& sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \
38+
&& apt-get install -y \
39+
postgresql-$PG_MAJOR=$PG_VERSION \
40+
postgresql-contrib-$PG_MAJOR=$PG_VERSION \
41+
&& rm -rf /var/lib/apt/lists/*
42+
43+
# make the sample config easier to munge (and "correct by default")
44+
RUN mv -v /usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample /usr/share/postgresql/ \
45+
&& ln -sv ../postgresql.conf.sample /usr/share/postgresql/$PG_MAJOR/ \
46+
&& sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample
47+
48+
RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
49+
50+
ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
51+
ENV PGDATA /var/lib/postgresql/data
52+
VOLUME /var/lib/postgresql/data
53+
54+
COPY docker-entrypoint.sh /
55+
56+
ENTRYPOINT ["/docker-entrypoint.sh"]
57+
58+
EXPOSE 5432
59+
CMD ["postgres"]

9.6/docker-entrypoint.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ "${1:0:1}" = '-' ]; then
5+
set -- postgres "$@"
6+
fi
7+
8+
if [ "$1" = 'postgres' ]; then
9+
mkdir -p "$PGDATA"
10+
chmod 700 "$PGDATA"
11+
chown -R postgres "$PGDATA"
12+
13+
chmod g+s /run/postgresql
14+
chown -R postgres /run/postgresql
15+
16+
# look specifically for PG_VERSION, as it is expected in the DB dir
17+
if [ ! -s "$PGDATA/PG_VERSION" ]; then
18+
eval "gosu postgres initdb $POSTGRES_INITDB_ARGS"
19+
20+
# check password first so we can output the warning before postgres
21+
# messes it up
22+
if [ "$POSTGRES_PASSWORD" ]; then
23+
pass="PASSWORD '$POSTGRES_PASSWORD'"
24+
authMethod=md5
25+
else
26+
# The - option suppresses leading tabs but *not* spaces. :)
27+
cat >&2 <<-'EOWARN'
28+
****************************************************
29+
WARNING: No password has been set for the database.
30+
This will allow anyone with access to the
31+
Postgres port to access your database. In
32+
Docker's default configuration, this is
33+
effectively any other container on the same
34+
system.
35+
36+
Use "-e POSTGRES_PASSWORD=password" to set
37+
it in "docker run".
38+
****************************************************
39+
EOWARN
40+
41+
pass=
42+
authMethod=trust
43+
fi
44+
45+
{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA/pg_hba.conf"
46+
47+
# internal start of server in order to allow set-up using psql-client
48+
# does not listen on external TCP/IP and waits until start finishes
49+
gosu postgres pg_ctl -D "$PGDATA" \
50+
-o "-c listen_addresses='localhost'" \
51+
-w start
52+
53+
: ${POSTGRES_USER:=postgres}
54+
: ${POSTGRES_DB:=$POSTGRES_USER}
55+
export POSTGRES_USER POSTGRES_DB
56+
57+
psql=( psql -v ON_ERROR_STOP=1 )
58+
59+
if [ "$POSTGRES_DB" != 'postgres' ]; then
60+
"${psql[@]}" --username postgres <<-EOSQL
61+
CREATE DATABASE "$POSTGRES_DB" ;
62+
EOSQL
63+
echo
64+
fi
65+
66+
if [ "$POSTGRES_USER" = 'postgres' ]; then
67+
op='ALTER'
68+
else
69+
op='CREATE'
70+
fi
71+
"${psql[@]}" --username postgres <<-EOSQL
72+
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
73+
EOSQL
74+
echo
75+
76+
psql+=( --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" )
77+
78+
echo
79+
for f in /docker-entrypoint-initdb.d/*; do
80+
case "$f" in
81+
*.sh) echo "$0: running $f"; . "$f" ;;
82+
*.sql) echo "$0: running $f"; "${psql[@]}" < "$f"; echo ;;
83+
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
84+
*) echo "$0: ignoring $f" ;;
85+
esac
86+
echo
87+
done
88+
89+
gosu postgres pg_ctl -D "$PGDATA" -m fast -w stop
90+
91+
echo
92+
echo 'PostgreSQL init process complete; ready for start up.'
93+
echo
94+
fi
95+
96+
exec gosu postgres "$@"
97+
fi
98+
99+
exec "$@"

0 commit comments

Comments
 (0)