Skip to content

Commit 6fdc13e

Browse files
committed
feat(postgres): use docker's official postgres:11 image
1 parent 263f50e commit 6fdc13e

File tree

3 files changed

+55
-56
lines changed

3 files changed

+55
-56
lines changed

Dockerfile

Lines changed: 19 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,42 @@
1-
FROM quay.io/deis/base:v0.3.6
1+
FROM postgres:11
22

3-
ENV LANG=en_US.utf8 \
4-
PG_MAJOR=9.4 \
5-
PG_VERSION=9.4.17-1.pgdg16.04+1 \
6-
PGDATA=/var/lib/postgresql/data
7-
8-
# Set this separately from those above since it depends on one of them
9-
ENV PATH=/usr/lib/postgresql/$PG_MAJOR/bin:$PATH
10-
11-
# Add postgres user and group
12-
RUN adduser --system \
13-
--shell /bin/bash \
14-
--disabled-password \
15-
--group \
16-
postgres
3+
ARG DEBIAN_FRONTEND=noninteractive
174

185
RUN buildDeps='gcc git libffi-dev libssl-dev python3-dev python3-pip python3-wheel' && \
19-
localedef -i en_US -c -f UTF-8 -A /etc/locale.alias en_US.UTF-8 && \
20-
export DEBIAN_FRONTEND=noninteractive && \
21-
apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 && \
22-
echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list && \
236
apt-get update && \
247
apt-get install -y --no-install-recommends \
258
$buildDeps \
269
gosu \
2710
lzop \
28-
postgresql-$PG_MAJOR=$PG_VERSION \
29-
postgresql-contrib-$PG_MAJOR=$PG_VERSION \
11+
libpq-dev \
3012
pv \
3113
python3 \
32-
postgresql-common \
3314
util-linux \
3415
# swift package needs pkg_resources and setuptools
3516
python3-pkg-resources \
36-
python3-setuptools && \
17+
python3-setuptools \
18+
python3-pip && \
3719
ln -sf /usr/bin/python3 /usr/bin/python && \
38-
ln -sf /usr/bin/pip3 /usr/bin/pip && \
39-
mkdir -p /run/postgresql && \
40-
chown -R postgres /run/postgresql && \
41-
# setuptools from ubuntu archives is too old for googleapis-common-protos
42-
pip install --upgrade setuptools && \
20+
ln -sf /usr/bin/pip3 /usr/bin/pip
21+
22+
# setuptools from ubuntu archives is too old for googleapis-common-protos
23+
RUN pip install --upgrade setuptools && \
4324
pip install --disable-pip-version-check --no-cache-dir \
44-
envdir==0.7 \
45-
wal-e[aws,azure,google,swift]==v1.0.2 \
46-
# pin azure-storage to version wal-e uses (see docker-entrypoint.sh)
47-
azure-storage==0.20.0 && \
48-
# "upgrade" boto to 2.43.0 + the patch to fix minio connections
49-
pip install --disable-pip-version-check --no-cache-dir --upgrade git+https://github.com/teamhephy/boto@88c980e56d1053892eb940d43a15a68af4ebb5e6 && \
50-
# cleanup
51-
apt-get purge -y --auto-remove $buildDeps && \
25+
envdir==1.0.1 \
26+
wal-e[aws,azure,google,swift]==1.1.0 \
27+
gcloud==0.18.3 \
28+
oauth2client==4.1.3 \
29+
azure-storage==0.20.0
30+
31+
# cleanup
32+
RUN apt-get purge -y --auto-remove $buildDeps && \
5233
apt-get autoremove -y && \
53-
apt-get clean -y && \
54-
# package up license files if any by appending to existing tar
55-
COPYRIGHT_TAR='/usr/share/copyrights.tar' && \
56-
gunzip -f $COPYRIGHT_TAR.gz && \
57-
tar -rf $COPYRIGHT_TAR /usr/share/doc/*/copyright && \
58-
gzip $COPYRIGHT_TAR && \
59-
rm -rf \
60-
/usr/share/doc \
61-
/usr/share/man \
62-
/usr/share/info \
63-
/usr/share/locale \
64-
/var/lib/apt/lists/* \
65-
/var/log/* \
66-
/var/cache/debconf/* \
67-
/etc/systemd \
68-
/lib/lsb \
69-
/lib/udev \
70-
/usr/lib/x86_64-linux-gnu/gconv/IBM* \
71-
/usr/lib/x86_64-linux-gnu/gconv/EBC* && \
72-
bash -c "mkdir -p /usr/share/man/man{1..8}"
34+
apt-get clean -y
7335

7436
COPY rootfs /
7537
ENV WALE_ENVDIR=/etc/wal-e.d/env
7638
RUN mkdir -p $WALE_ENVDIR
39+
RUN python3 /patch_wal_e.py
7740

7841
CMD ["/docker-entrypoint.sh", "postgres"]
7942
EXPOSE 5432

rootfs/docker-entrypoint-initdb.d/003_restore_from_backup.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ EOF
5555
-w start
5656
fi
5757

58+
echo "Waiting for recovery completion..."
59+
while [ ! -f "$PGDATA/recovery.done" ]
60+
do
61+
sleep 1
62+
done
63+
5864
echo "Performing an initial backup..."
5965
gosu postgres envdir "$WALE_ENVDIR" wal-e backup-push "$PGDATA"
6066

rootfs/patch_wal_e.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
patch_script = """
2+
3+
def patch_s3():
4+
import os
5+
from boto.auth import HmacAuthV4Handler
6+
init = HmacAuthV4Handler.__init__
7+
def wrap(self, *args, **kwargs):
8+
init(self, *args, **kwargs)
9+
self.region_name = os.getenv('AWS_REGION', self.region_name)
10+
HmacAuthV4Handler.__init__ = wrap
11+
patch_s3()
12+
13+
"""
14+
15+
16+
def main():
17+
result_list = []
18+
with open("/usr/local/bin/wal-e", "r") as f:
19+
has_patched = False
20+
for line in f:
21+
if not has_patched and line.startswith('import'):
22+
result_list.append(patch_script)
23+
has_patched = True
24+
result_list.append(line)
25+
with open("/usr/local/bin/wal-e", "w") as f:
26+
for line in result_list:
27+
f.write(line)
28+
29+
if __name__ == '__main__':
30+
main()

0 commit comments

Comments
 (0)