Skip to content

Commit e677b56

Browse files
committed
Add 9.5-alpha1
1 parent bfca9b8 commit e677b56

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

9.5/Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# vim:set ft=dockerfile:
2+
FROM debian:wheezy
3+
4+
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
5+
RUN groupadd -r postgres && useradd -r -g postgres postgres
6+
7+
# grab gosu for easy step-down from root
8+
RUN gpg --keyserver pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
9+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \
10+
&& curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture)" \
11+
&& curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \
12+
&& gpg --verify /usr/local/bin/gosu.asc \
13+
&& rm /usr/local/bin/gosu.asc \
14+
&& chmod +x /usr/local/bin/gosu \
15+
&& apt-get purge -y --auto-remove curl
16+
17+
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
18+
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
19+
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
20+
ENV LANG en_US.utf8
21+
22+
RUN mkdir /docker-entrypoint-initdb.d
23+
24+
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
25+
26+
ENV PG_MAJOR 9.5
27+
ENV PG_VERSION 9.5~alpha1-1.pgdg70+1
28+
29+
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
30+
31+
RUN apt-get update \
32+
&& apt-get install -y postgresql-common \
33+
&& sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \
34+
&& apt-get install -y \
35+
postgresql-$PG_MAJOR=$PG_VERSION \
36+
postgresql-contrib-$PG_MAJOR=$PG_VERSION \
37+
&& rm -rf /var/lib/apt/lists/*
38+
39+
RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
40+
41+
ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
42+
ENV PGDATA /var/lib/postgresql/data
43+
VOLUME /var/lib/postgresql/data
44+
45+
COPY docker-entrypoint.sh /
46+
47+
ENTRYPOINT ["/docker-entrypoint.sh"]
48+
49+
EXPOSE 5432
50+
CMD ["postgres"]

9.5/docker-entrypoint.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ "$1" = 'postgres' ]; then
5+
chown -R postgres "$PGDATA"
6+
7+
chmod g+s /run/postgresql
8+
chown -R postgres:postgres /run/postgresql
9+
10+
if [ -z "$(ls -A "$PGDATA")" ]; then
11+
gosu postgres initdb
12+
13+
sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf
14+
15+
# check password first so we can ouptut the warning before postgres
16+
# messes it up
17+
if [ "$POSTGRES_PASSWORD" ]; then
18+
pass="PASSWORD '$POSTGRES_PASSWORD'"
19+
authMethod=md5
20+
else
21+
# The - option suppresses leading tabs but *not* spaces. :)
22+
cat >&2 <<-'EOWARN'
23+
****************************************************
24+
WARNING: No password has been set for the database.
25+
This will allow anyone with access to the
26+
Postgres port to access your database. In
27+
Docker's default configuration, this is
28+
effectively any other container on the same
29+
system.
30+
31+
Use "-e POSTGRES_PASSWORD=password" to set
32+
it in "docker run".
33+
****************************************************
34+
EOWARN
35+
36+
pass=
37+
authMethod=trust
38+
fi
39+
40+
: ${POSTGRES_USER:=postgres}
41+
: ${POSTGRES_DB:=$POSTGRES_USER}
42+
43+
if [ "$POSTGRES_DB" != 'postgres' ]; then
44+
gosu postgres postgres --single -jE <<-EOSQL
45+
CREATE DATABASE "$POSTGRES_DB" ;
46+
EOSQL
47+
echo
48+
fi
49+
50+
if [ "$POSTGRES_USER" = 'postgres' ]; then
51+
op='ALTER'
52+
else
53+
op='CREATE'
54+
fi
55+
56+
gosu postgres postgres --single -jE <<-EOSQL
57+
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
58+
EOSQL
59+
echo
60+
61+
{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA"/pg_hba.conf
62+
63+
if [ -d /docker-entrypoint-initdb.d ]; then
64+
for f in /docker-entrypoint-initdb.d/*.sh; do
65+
[ -f "$f" ] && . "$f"
66+
done
67+
fi
68+
fi
69+
70+
exec gosu postgres "$@"
71+
fi
72+
73+
exec "$@"

0 commit comments

Comments
 (0)