Skip to content

Commit a9c1b15

Browse files
committed
Sync a bit more with the Debian configure flags (adding comments for where we differ) and add all versions (including "update.sh" and "generate-stackbrew-library.sh" changes, with our new template)
1 parent 688e034 commit a9c1b15

15 files changed

+1122
-49
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ services: docker
33

44
env:
55
- VERSION=9.6
6+
- VERSION=9.6 VARIANT=alpine
67
- VERSION=9.5
78
- VERSION=9.5 VARIANT=alpine
89
- VERSION=9.4
10+
- VERSION=9.4 VARIANT=alpine
911
- VERSION=9.3
12+
- VERSION=9.3 VARIANT=alpine
1013
- VERSION=9.2
14+
- VERSION=9.2 VARIANT=alpine
1115

1216
install:
1317
- git clone https://github.com/docker-library/official-images.git ~/official-images

9.2/alpine/Dockerfile

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# vim:set ft=dockerfile:
2+
FROM alpine:3.4
3+
4+
# alpine includes "postgres" user/group in base install
5+
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6+
# /etc/group:34:postgres:x:70:
7+
8+
# su-exec (gosu-compatible) is installed further down
9+
10+
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
11+
# alpine doesn't require explicit locale-file generation
12+
ENV LANG en_US.utf8
13+
14+
RUN mkdir /docker-entrypoint-initdb.d
15+
16+
ENV PG_MAJOR 9.2
17+
ENV PG_VERSION 9.2.19
18+
ENV PG_SHA256 1d29d73a4f590fcc348280f13ac2ff6a0f72c94908c54e3c20b7ab1560e8dbad
19+
20+
RUN set -ex \
21+
\
22+
&& apk add --no-cache --virtual .fetch-deps \
23+
ca-certificates \
24+
openssl \
25+
tar \
26+
\
27+
&& wget -O postgresql.tar.bz2 "https://ftp.postgresql.org/pub/source/v$PG_VERSION/postgresql-$PG_VERSION.tar.bz2" \
28+
&& echo "$PG_SHA256 *postgresql.tar.bz2" | sha256sum -c - \
29+
&& mkdir -p /usr/src/postgresql \
30+
&& tar \
31+
--extract \
32+
--file postgresql.tar.bz2 \
33+
--directory /usr/src/postgresql \
34+
--strip-components 1 \
35+
&& rm postgresql.tar.bz2 \
36+
\
37+
&& apk add --no-cache --virtual .build-deps \
38+
bison \
39+
flex \
40+
gcc \
41+
# krb5-dev \
42+
libc-dev \
43+
libedit-dev \
44+
libxml2-dev \
45+
libxslt-dev \
46+
make \
47+
# openldap-dev \
48+
openssl-dev \
49+
perl \
50+
# perl-dev \
51+
# python-dev \
52+
# python3-dev \
53+
# tcl-dev \
54+
util-linux-dev \
55+
zlib-dev \
56+
\
57+
&& cd /usr/src/postgresql \
58+
# configure options taken from:
59+
# https://anonscm.debian.org/cgit/pkg-postgresql/postgresql.git/tree/debian/rules?h=9.5
60+
&& ./configure \
61+
# "/usr/src/postgresql/src/backend/access/common/tupconvert.c:105: undefined reference to `libintl_gettext'"
62+
# --enable-nls \
63+
--enable-integer-datetimes \
64+
--enable-thread-safety \
65+
--enable-tap-tests \
66+
# skip debugging info -- we want tiny size instead
67+
# --enable-debug \
68+
--disable-rpath \
69+
--with-uuid=e2fs \
70+
--with-gnu-ld \
71+
--with-pgport=5432 \
72+
--with-system-tzdata=/usr/share/zoneinfo \
73+
--prefix=/usr/local \
74+
\
75+
# these make our image abnormally large (at least 100MB larger), which seems uncouth for an "Alpine" (ie, "small") variant :)
76+
# --with-krb5 \
77+
# --with-gssapi \
78+
# --with-ldap \
79+
# --with-tcl \
80+
# --with-perl \
81+
# --with-python \
82+
# --with-pam \
83+
--with-openssl \
84+
--with-libxml \
85+
--with-libxslt \
86+
&& make -j "$(getconf _NPROCESSORS_ONLN)" world \
87+
&& make install-world \
88+
&& make -C contrib install \
89+
\
90+
&& runDeps="$( \
91+
scanelf --needed --nobanner --recursive /usr/local \
92+
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
93+
| sort -u \
94+
| xargs -r apk info --installed \
95+
| sort -u \
96+
)" \
97+
&& apk add --no-cache --virtual .postgresql-rundeps \
98+
$runDeps \
99+
bash \
100+
su-exec \
101+
&& apk del .build-deps \
102+
&& cd / \
103+
&& rm -rf \
104+
/usr/src/postgresql \
105+
/usr/local/include/* \
106+
&& find /usr/local -name '*.a' -delete
107+
108+
RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
109+
110+
ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
111+
ENV PGDATA /var/lib/postgresql/data
112+
VOLUME /var/lib/postgresql/data
113+
114+
COPY docker-entrypoint.sh /
115+
116+
ENTRYPOINT ["/docker-entrypoint.sh"]
117+
118+
EXPOSE 5432
119+
CMD ["postgres"]

9.2/alpine/docker-entrypoint.sh

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

9.3/alpine/Dockerfile

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# vim:set ft=dockerfile:
2+
FROM alpine:3.4
3+
4+
# alpine includes "postgres" user/group in base install
5+
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6+
# /etc/group:34:postgres:x:70:
7+
8+
# su-exec (gosu-compatible) is installed further down
9+
10+
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
11+
# alpine doesn't require explicit locale-file generation
12+
ENV LANG en_US.utf8
13+
14+
RUN mkdir /docker-entrypoint-initdb.d
15+
16+
ENV PG_MAJOR 9.3
17+
ENV PG_VERSION 9.3.15
18+
ENV PG_SHA256 a9fcba1446a93aa95e3e1b6535756f0472d10b0f267a0845f8b2b29f89de5c4f
19+
20+
RUN set -ex \
21+
\
22+
&& apk add --no-cache --virtual .fetch-deps \
23+
ca-certificates \
24+
openssl \
25+
tar \
26+
\
27+
&& wget -O postgresql.tar.bz2 "https://ftp.postgresql.org/pub/source/v$PG_VERSION/postgresql-$PG_VERSION.tar.bz2" \
28+
&& echo "$PG_SHA256 *postgresql.tar.bz2" | sha256sum -c - \
29+
&& mkdir -p /usr/src/postgresql \
30+
&& tar \
31+
--extract \
32+
--file postgresql.tar.bz2 \
33+
--directory /usr/src/postgresql \
34+
--strip-components 1 \
35+
&& rm postgresql.tar.bz2 \
36+
\
37+
&& apk add --no-cache --virtual .build-deps \
38+
bison \
39+
flex \
40+
gcc \
41+
# krb5-dev \
42+
libc-dev \
43+
libedit-dev \
44+
libxml2-dev \
45+
libxslt-dev \
46+
make \
47+
# openldap-dev \
48+
openssl-dev \
49+
perl \
50+
# perl-dev \
51+
# python-dev \
52+
# python3-dev \
53+
# tcl-dev \
54+
util-linux-dev \
55+
zlib-dev \
56+
\
57+
&& cd /usr/src/postgresql \
58+
# configure options taken from:
59+
# https://anonscm.debian.org/cgit/pkg-postgresql/postgresql.git/tree/debian/rules?h=9.5
60+
&& ./configure \
61+
# "/usr/src/postgresql/src/backend/access/common/tupconvert.c:105: undefined reference to `libintl_gettext'"
62+
# --enable-nls \
63+
--enable-integer-datetimes \
64+
--enable-thread-safety \
65+
--enable-tap-tests \
66+
# skip debugging info -- we want tiny size instead
67+
# --enable-debug \
68+
--disable-rpath \
69+
--with-uuid=e2fs \
70+
--with-gnu-ld \
71+
--with-pgport=5432 \
72+
--with-system-tzdata=/usr/share/zoneinfo \
73+
--prefix=/usr/local \
74+
\
75+
# these make our image abnormally large (at least 100MB larger), which seems uncouth for an "Alpine" (ie, "small") variant :)
76+
# --with-krb5 \
77+
# --with-gssapi \
78+
# --with-ldap \
79+
# --with-tcl \
80+
# --with-perl \
81+
# --with-python \
82+
# --with-pam \
83+
--with-openssl \
84+
--with-libxml \
85+
--with-libxslt \
86+
&& make -j "$(getconf _NPROCESSORS_ONLN)" world \
87+
&& make install-world \
88+
&& make -C contrib install \
89+
\
90+
&& runDeps="$( \
91+
scanelf --needed --nobanner --recursive /usr/local \
92+
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
93+
| sort -u \
94+
| xargs -r apk info --installed \
95+
| sort -u \
96+
)" \
97+
&& apk add --no-cache --virtual .postgresql-rundeps \
98+
$runDeps \
99+
bash \
100+
su-exec \
101+
&& apk del .build-deps \
102+
&& cd / \
103+
&& rm -rf \
104+
/usr/src/postgresql \
105+
/usr/local/include/* \
106+
&& find /usr/local -name '*.a' -delete
107+
108+
RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
109+
110+
ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
111+
ENV PGDATA /var/lib/postgresql/data
112+
VOLUME /var/lib/postgresql/data
113+
114+
COPY docker-entrypoint.sh /
115+
116+
ENTRYPOINT ["/docker-entrypoint.sh"]
117+
118+
EXPOSE 5432
119+
CMD ["postgres"]

0 commit comments

Comments
 (0)