Skip to content

Commit 0801767

Browse files
authored
chore(Dockerfile): consolidate a few chmod and chown into one layer (#145)
Get gosu from Ubuntu (1.7 gosu) and combine pip installs into one step
1 parent bd61905 commit 0801767

1 file changed

Lines changed: 45 additions & 38 deletions

File tree

Dockerfile

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,51 @@ RUN adduser --system \
1515
--group \
1616
postgres
1717

18-
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
19-
&& curl -L -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture)" \
20-
&& curl -L -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \
21-
&& gpg --verify /usr/local/bin/gosu.asc \
22-
&& rm /usr/local/bin/gosu.asc \
23-
&& chmod +x /usr/local/bin/gosu \
24-
&& localedef -i en_US -c -f UTF-8 -A /etc/locale.alias en_US.UTF-8 \
25-
&& apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 \
26-
&& echo 'deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list \
27-
&& apt-get update \
28-
&& export DEBIAN_FRONTEND=noninteractive \
29-
&& apt-get install -y postgresql-common util-linux \
30-
&& sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \
31-
&& apt-get install -y --no-install-recommends \
32-
gcc \
33-
git \
34-
libssl-dev \
35-
libffi-dev \
36-
lzop \
37-
postgresql-$PG_MAJOR=$PG_VERSION \
38-
postgresql-contrib-$PG_MAJOR=$PG_VERSION \
39-
pv \
40-
python \
41-
python-dev \
42-
&& mkdir -p /var/run/postgresql \
43-
&& chown -R postgres /var/run/postgresql \
44-
&& curl -sSL https://raw.githubusercontent.com/pypa/pip/7.1.2/contrib/get-pip.py | python - \
45-
&& pip install --disable-pip-version-check --no-cache-dir git+https://github.com/deis/wal-e.git@380821a6c4ea4f98a244680d7c6c5b04b8c694b3 \
46-
&& pip install --disable-pip-version-check --no-cache-dir google-gax===0.12.5 \
47-
&& pip install --disable-pip-version-check --no-cache-dir envdir \
48-
&& apt-get remove -y --auto-remove --purge \
49-
gcc \
50-
git \
51-
libssl-dev \
52-
libffi-dev \
53-
python-dev \
54-
&& apt-get clean \
55-
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man /usr/share/doc
18+
RUN buildDeps='gcc git libffi-dev libssl-dev python-dev python-pip python-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/ jessie-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list && \
23+
apt-get update && \
24+
apt-get install -y --no-install-recommends \
25+
$buildDeps \
26+
gosu \
27+
lzop \
28+
postgresql-$PG_MAJOR=$PG_VERSION \
29+
postgresql-contrib-$PG_MAJOR=$PG_VERSION \
30+
pv \
31+
python \
32+
postgresql-common \
33+
util-linux \
34+
# swift package needs pkg_resources and setuptools
35+
python-pkg-resources \
36+
python-setuptools && \
37+
mkdir -p /run/postgresql && \
38+
chown -R postgres /run/postgresql && \
39+
pip install --disable-pip-version-check --no-cache-dir git+https://github.com/deis/wal-e.git@380821a6c4ea4f98a244680d7c6c5b04b8c694b3 \
40+
google-gax===0.12.5 \
41+
envdir && \
42+
# cleanup
43+
apt-get purge -y --auto-remove $buildDeps && \
44+
apt-get autoremove -y && \
45+
apt-get clean -y && \
46+
# package up license files if any by appending to existing tar
47+
COPYRIGHT_TAR='/usr/share/copyrights.tar'; \
48+
gunzip $COPYRIGHT_TAR.gz; tar -rf $COPYRIGHT_TAR /usr/share/doc/*/copyright; gzip $COPYRIGHT_TAR && \
49+
rm -rf \
50+
/usr/share/doc \
51+
/usr/share/man \
52+
/usr/share/info \
53+
/usr/share/locale \
54+
/var/lib/apt/lists/* \
55+
/var/log/* \
56+
/var/cache/debconf/* \
57+
/etc/systemd \
58+
/lib/lsb \
59+
/lib/udev \
60+
/usr/lib/x86_64-linux-gnu/gconv/IBM* \
61+
/usr/lib/x86_64-linux-gnu/gconv/EBC* && \
62+
bash -c "mkdir -p /usr/share/man/man{1..8}"
5663

5764
COPY rootfs /
5865
ENV WALE_ENVDIR=/etc/wal-e.d/env

0 commit comments

Comments
 (0)