Skip to content

Commit 4002753

Browse files
author
Matthew Fisher
committed
Merge pull request #2206 from aledbf/reduce_database_size
ref(database): reduce image size
2 parents 08ae756 + 0631a6a commit 4002753

2 files changed

Lines changed: 54 additions & 29 deletions

File tree

database/Dockerfile

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,8 @@ RUN curl -sSL -o /usr/local/bin/etcdctl https://s3-us-west-2.amazonaws.com/opdem
1313
RUN curl -sSL -o /usr/local/bin/confd https://s3-us-west-2.amazonaws.com/opdemand/confd-v0.5.0-json \
1414
&& chmod +x /usr/local/bin/confd
1515

16-
# install postgresql 9.3 from postgresql.org repository as well as requirements for building wal-e
17-
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list
18-
RUN curl -sk https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
19-
RUN apt-get update && apt-get install -yq \
20-
curl \
21-
daemontools \
22-
file \
23-
gcc \
24-
git \
25-
libxml2-dev \
26-
libxslt1-dev \
27-
lzop \
28-
postgresql-9.3 \
29-
pv \
30-
python-dev
31-
32-
RUN /etc/init.d/postgresql stop
33-
34-
# install pip
35-
RUN curl -sSL https://raw.githubusercontent.com/pypa/pip/1.5.6/contrib/get-pip.py | python -
36-
37-
# install wal-e
38-
WORKDIR /tmp
39-
RUN git clone https://github.com/wal-e/wal-e.git
40-
WORKDIR /tmp/wal-e
41-
RUN git checkout c6f0d02
42-
RUN pip install .
43-
RUN mkdir -p /etc/wal-e.d/env
44-
RUN chown -R root:postgres /etc/wal-e.d
16+
ADD build.sh /tmp/build.sh
17+
RUN DOCKER_BUILD=true /tmp/build.sh
4518

4619
# define the execution environment
4720
WORKDIR /app

database/build.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ -z $DOCKER_BUILD ]]; then
4+
echo
5+
echo "Note: this script is intended for use by the Dockerfile and not as a way to build the database locally"
6+
echo
7+
exit 1
8+
fi
9+
10+
# install postgresql 9.3 from postgresql.org repository as well as requirements for building wal-e
11+
echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list
12+
curl -sk https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
13+
apt-get update && apt-get install -yq \
14+
curl \
15+
daemontools \
16+
file \
17+
gcc \
18+
git \
19+
libxml2-dev \
20+
libxslt1-dev \
21+
lzop \
22+
postgresql-9.3 \
23+
pv \
24+
python-dev
25+
26+
/etc/init.d/postgresql stop
27+
28+
# install pip
29+
curl -sSL https://raw.githubusercontent.com/pypa/pip/1.5.6/contrib/get-pip.py | python -
30+
31+
# install wal-e
32+
cd /tmp
33+
git clone https://github.com/wal-e/wal-e.git
34+
35+
cd /tmp/wal-e
36+
git checkout c6f0d02
37+
38+
pip install .
39+
40+
mkdir -p /etc/wal-e.d/env
41+
42+
chown -R root:postgres /etc/wal-e.d
43+
44+
# cleanup. indicate that python, libpq and libyanl are required packages.
45+
apt-mark unmarkauto python curl daemontools file libxml2-dev \
46+
libxslt1-dev lzop postgresql-9.3 pv && \
47+
apt-get remove -y --purge python-dev gcc cpp libpq-dev libyaml-dev git && \
48+
apt-get autoremove -y --purge && \
49+
apt-get clean -y && \
50+
rm -Rf /usr/share/man /usr/share/doc && \
51+
rm -rf /tmp/* /var/tmp/* && \
52+
rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)