Skip to content

Commit 927a852

Browse files
committed
Add new 11 series beta
1 parent c372e3b commit 927a852

File tree

5 files changed

+625
-0
lines changed

5 files changed

+625
-0
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ env:
1414
- VERSION=9.3
1515
- VERSION=9.3 FORCE_DEB_BUILD=1
1616
- VERSION=9.3 VARIANT=alpine
17+
- VERSION=11
18+
- VERSION=11 FORCE_DEB_BUILD=1
19+
- VERSION=11 VARIANT=alpine
1720
- VERSION=10
1821
- VERSION=10 FORCE_DEB_BUILD=1
1922
- VERSION=10 VARIANT=alpine

11/Dockerfile

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# vim:set ft=dockerfile:
2+
FROM debian:stretch-slim
3+
4+
RUN set -ex; \
5+
if ! command -v gpg > /dev/null; then \
6+
apt-get update; \
7+
apt-get install -y --no-install-recommends \
8+
gnupg \
9+
dirmngr \
10+
; \
11+
rm -rf /var/lib/apt/lists/*; \
12+
fi
13+
14+
# explicitly set user/group IDs
15+
RUN groupadd -r postgres --gid=999 && useradd -r -g postgres --uid=999 postgres
16+
17+
# grab gosu for easy step-down from root
18+
ENV GOSU_VERSION 1.10
19+
RUN set -x \
20+
&& apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \
21+
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
22+
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
23+
&& export GNUPGHOME="$(mktemp -d)" \
24+
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
25+
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
26+
&& rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \
27+
&& chmod +x /usr/local/bin/gosu \
28+
&& gosu nobody true \
29+
&& apt-get purge -y --auto-remove ca-certificates wget
30+
31+
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
32+
RUN set -eux; \
33+
if [ -f /etc/dpkg/dpkg.cfg.d/docker ]; then \
34+
# if this file exists, we're likely in "debian:xxx-slim", and locales are thus being excluded so we need to remove that exclusion (since we need locales)
35+
grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
36+
sed -ri '/\/usr\/share\/locale/d' /etc/dpkg/dpkg.cfg.d/docker; \
37+
! grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
38+
fi; \
39+
apt-get update; apt-get install -y locales; rm -rf /var/lib/apt/lists/*; \
40+
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
41+
ENV LANG en_US.utf8
42+
43+
# install "nss_wrapper" in case we need to fake "/etc/passwd" and "/etc/group" (especially for OpenShift)
44+
# https://github.com/docker-library/postgres/issues/359
45+
# https://cwrap.org/nss_wrapper.html
46+
RUN set -eux; \
47+
apt-get update; \
48+
apt-get install -y --no-install-recommends libnss-wrapper; \
49+
rm -rf /var/lib/apt/lists/*
50+
51+
RUN mkdir /docker-entrypoint-initdb.d
52+
53+
RUN set -ex; \
54+
# pub 4096R/ACCC4CF8 2011-10-13 [expires: 2019-07-02]
55+
# Key fingerprint = B97B 0AFC AA1A 47F0 44F2 44A0 7FCC 7D46 ACCC 4CF8
56+
# uid PostgreSQL Debian Repository
57+
key='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8'; \
58+
export GNUPGHOME="$(mktemp -d)"; \
59+
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
60+
gpg --export "$key" > /etc/apt/trusted.gpg.d/postgres.gpg; \
61+
rm -rf "$GNUPGHOME"; \
62+
apt-key list
63+
64+
ENV PG_MAJOR 11
65+
ENV PG_VERSION 11~beta1-2.pgdg90+1
66+
67+
RUN set -ex; \
68+
\
69+
dpkgArch="$(dpkg --print-architecture)"; \
70+
case "$dpkgArch" in \
71+
amd64|i386|ppc64el) \
72+
# arches officialy built by upstream
73+
echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main $PG_MAJOR" > /etc/apt/sources.list.d/pgdg.list; \
74+
apt-get update; \
75+
;; \
76+
*) \
77+
# we're on an architecture upstream doesn't officially build for
78+
# let's build binaries from their published source packages
79+
echo "deb-src http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main $PG_MAJOR" > /etc/apt/sources.list.d/pgdg.list; \
80+
\
81+
tempDir="$(mktemp -d)"; \
82+
cd "$tempDir"; \
83+
\
84+
savedAptMark="$(apt-mark showmanual)"; \
85+
\
86+
# build .deb files from upstream's source packages (which are verified by apt-get)
87+
apt-get update; \
88+
apt-get build-dep -y \
89+
postgresql-common pgdg-keyring \
90+
"postgresql-$PG_MAJOR=$PG_VERSION" \
91+
; \
92+
DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
93+
apt-get source --compile \
94+
postgresql-common pgdg-keyring \
95+
"postgresql-$PG_MAJOR=$PG_VERSION" \
96+
; \
97+
# we don't remove APT lists here because they get re-downloaded and removed later
98+
\
99+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
100+
# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies)
101+
apt-mark showmanual | xargs apt-mark auto > /dev/null; \
102+
apt-mark manual $savedAptMark; \
103+
\
104+
# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be)
105+
ls -lAFh; \
106+
dpkg-scanpackages . > Packages; \
107+
grep '^Package: ' Packages; \
108+
echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list; \
109+
# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
110+
# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
111+
# ...
112+
# E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
113+
apt-get -o Acquire::GzipIndexes=false update; \
114+
;; \
115+
esac; \
116+
\
117+
apt-get install -y postgresql-common; \
118+
sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf; \
119+
apt-get install -y \
120+
"postgresql-$PG_MAJOR=$PG_VERSION" \
121+
; \
122+
\
123+
rm -rf /var/lib/apt/lists/*; \
124+
\
125+
if [ -n "$tempDir" ]; then \
126+
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
127+
apt-get purge -y --auto-remove; \
128+
rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \
129+
fi
130+
131+
# make the sample config easier to munge (and "correct by default")
132+
RUN mv -v "/usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample" /usr/share/postgresql/ \
133+
&& ln -sv ../postgresql.conf.sample "/usr/share/postgresql/$PG_MAJOR/" \
134+
&& sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample
135+
136+
RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql
137+
138+
ENV PATH $PATH:/usr/lib/postgresql/$PG_MAJOR/bin
139+
ENV PGDATA /var/lib/postgresql/data
140+
RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA" # this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values)
141+
VOLUME /var/lib/postgresql/data
142+
143+
COPY docker-entrypoint.sh /usr/local/bin/
144+
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
145+
ENTRYPOINT ["docker-entrypoint.sh"]
146+
147+
EXPOSE 5432
148+
CMD ["postgres"]

11/alpine/Dockerfile

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# vim:set ft=dockerfile:
2+
FROM alpine:3.7
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+
# the home directory for the postgres user, however, is not created by default
8+
# see https://github.com/docker-library/postgres/issues/274
9+
RUN set -ex; \
10+
postgresHome="$(getent passwd postgres)"; \
11+
postgresHome="$(echo "$postgresHome" | cut -d: -f6)"; \
12+
[ "$postgresHome" = '/var/lib/postgresql' ]; \
13+
mkdir -p "$postgresHome"; \
14+
chown -R postgres:postgres "$postgresHome"
15+
16+
# su-exec (gosu-compatible) is installed further down
17+
18+
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
19+
# alpine doesn't require explicit locale-file generation
20+
ENV LANG en_US.utf8
21+
22+
RUN mkdir /docker-entrypoint-initdb.d
23+
24+
ENV PG_MAJOR 11
25+
ENV PG_VERSION 11beta1
26+
ENV PG_SHA256 17889cbffdf4f07c193b16d76b2f9c45daa3f2ab225acd8d7f01521949cb1355
27+
28+
RUN set -ex \
29+
\
30+
&& apk add --no-cache --virtual .fetch-deps \
31+
ca-certificates \
32+
openssl \
33+
tar \
34+
\
35+
&& wget -O postgresql.tar.bz2 "https://ftp.postgresql.org/pub/source/v$PG_VERSION/postgresql-$PG_VERSION.tar.bz2" \
36+
&& echo "$PG_SHA256 *postgresql.tar.bz2" | sha256sum -c - \
37+
&& mkdir -p /usr/src/postgresql \
38+
&& tar \
39+
--extract \
40+
--file postgresql.tar.bz2 \
41+
--directory /usr/src/postgresql \
42+
--strip-components 1 \
43+
&& rm postgresql.tar.bz2 \
44+
\
45+
&& apk add --no-cache --virtual .build-deps \
46+
bison \
47+
coreutils \
48+
dpkg-dev dpkg \
49+
flex \
50+
gcc \
51+
# krb5-dev \
52+
libc-dev \
53+
libedit-dev \
54+
libxml2-dev \
55+
libxslt-dev \
56+
make \
57+
# openldap-dev \
58+
openssl-dev \
59+
# configure: error: prove not found
60+
perl-utils \
61+
# configure: error: Perl module IPC::Run is required to run TAP tests
62+
perl-ipc-run \
63+
# perl-dev \
64+
# python-dev \
65+
# python3-dev \
66+
# tcl-dev \
67+
util-linux-dev \
68+
zlib-dev \
69+
\
70+
&& cd /usr/src/postgresql \
71+
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
72+
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
73+
&& awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new \
74+
&& grep '/var/run/postgresql' src/include/pg_config_manual.h.new \
75+
&& mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h \
76+
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
77+
# explicitly update autoconf config.guess and config.sub so they support more arches/libcs
78+
&& wget -O config/config.guess 'https://git.savannah.gnu.org/cgit/config.git/plain/config.guess?id=7d3d27baf8107b630586c962c057e22149653deb' \
79+
&& wget -O config/config.sub 'https://git.savannah.gnu.org/cgit/config.git/plain/config.sub?id=7d3d27baf8107b630586c962c057e22149653deb' \
80+
# configure options taken from:
81+
# https://anonscm.debian.org/cgit/pkg-postgresql/postgresql.git/tree/debian/rules?h=9.5
82+
&& ./configure \
83+
--build="$gnuArch" \
84+
# "/usr/src/postgresql/src/backend/access/common/tupconvert.c:105: undefined reference to `libintl_gettext'"
85+
# --enable-nls \
86+
--enable-integer-datetimes \
87+
--enable-thread-safety \
88+
--enable-tap-tests \
89+
# skip debugging info -- we want tiny size instead
90+
# --enable-debug \
91+
--disable-rpath \
92+
--with-uuid=e2fs \
93+
--with-gnu-ld \
94+
--with-pgport=5432 \
95+
--with-system-tzdata=/usr/share/zoneinfo \
96+
--prefix=/usr/local \
97+
--with-includes=/usr/local/include \
98+
--with-libraries=/usr/local/lib \
99+
\
100+
# these make our image abnormally large (at least 100MB larger), which seems uncouth for an "Alpine" (ie, "small") variant :)
101+
# --with-krb5 \
102+
# --with-gssapi \
103+
# --with-ldap \
104+
# --with-tcl \
105+
# --with-perl \
106+
# --with-python \
107+
# --with-pam \
108+
--with-openssl \
109+
--with-libxml \
110+
--with-libxslt \
111+
&& make -j "$(nproc)" world \
112+
&& make install-world \
113+
&& make -C contrib install \
114+
\
115+
&& runDeps="$( \
116+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
117+
| tr ',' '\n' \
118+
| sort -u \
119+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
120+
)" \
121+
&& apk add --no-cache --virtual .postgresql-rundeps \
122+
$runDeps \
123+
bash \
124+
su-exec \
125+
# tzdata is optional, but only adds around 1Mb to image size and is recommended by Django documentation:
126+
# https://docs.djangoproject.com/en/1.10/ref/databases/#optimizing-postgresql-s-configuration
127+
tzdata \
128+
&& apk del .fetch-deps .build-deps \
129+
&& cd / \
130+
&& rm -rf \
131+
/usr/src/postgresql \
132+
/usr/local/share/doc \
133+
/usr/local/share/man \
134+
&& find /usr/local -name '*.a' -delete
135+
136+
# make the sample config easier to munge (and "correct by default")
137+
RUN sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample
138+
139+
RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql
140+
141+
ENV PGDATA /var/lib/postgresql/data
142+
RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA" # this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values)
143+
VOLUME /var/lib/postgresql/data
144+
145+
COPY docker-entrypoint.sh /usr/local/bin/
146+
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
147+
ENTRYPOINT ["docker-entrypoint.sh"]
148+
149+
EXPOSE 5432
150+
CMD ["postgres"]

0 commit comments

Comments
 (0)