Skip to content

Commit b2c0be7

Browse files
authored
Purge build deps to shrink image from 2.32 GB to 1.76 GB (CircleCI-Public#92)
The space savings are for the 12.15 image, built locally before and after this commit. Combine the pg and pg_cron layers to avoid installing & purging build-depends several times. Gosu is used in entrypoint, so it is not purged. locales is required by Pg at runtime, so it is not purged.
1 parent 62dab19 commit b2c0be7

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Dockerfile.template

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ ENV PGTAP_VERSION 1.2.0
2020
ENV PARTMAN_VERSION 4.7.2
2121

2222
USER root
23-
RUN apt-get update && apt-get install -y --no-install-recommends \
24-
clang \
23+
RUN BUILD_DEPS="clang \
2524
dirmngr \
2625
gnupg \
27-
gosu \
2826
libclang-dev \
2927
libicu-dev \
3028
libipc-run-perl \
@@ -40,11 +38,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4038
libxslt1-dev \
4139
llvm \
4240
llvm-dev \
43-
locales \
4441
postgresql-server-dev-all \
4542
python3-dev \
4643
tcl-dev \
47-
uuid-dev \
44+
uuid-dev" && \
45+
apt-get update && apt-get install -y --no-install-recommends \
46+
gosu \
47+
locales \
48+
$BUILD_DEPS \
4849
&& \
4950
rm -rf /var/lib/apt/lists/* && \
5051
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \
@@ -78,18 +79,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
7879
# we can change from world to world-bin in newer releases
7980
make world && \
8081
make install-world && \
81-
cd .. && rm -rf postgresql-${PG_VER}
82+
cd .. && rm -rf postgresql-${PG_VER} \
83+
&& \
84+
git clone --depth 1 https://github.com/citusdata/pg_cron.git /pg_cron && \
85+
cd /pg_cron && make && PATH=$PATH make install && \
86+
rm -rf /pg_cron && \
87+
apt-get purge -y --auto-remove $BUILD_DEPS
8288

8389
RUN curl -sSL "https://github.com/pgpartman/pg_partman/archive/v${PARTMAN_VERSION}.tar.gz" | tar -xz && \
8490
cd pg_partman-${PARTMAN_VERSION} && make NO_BGW=1 install && \
8591
cd .. && rm -rf pg_partman-${PARTMAN_VERSION}
8692

87-
# clones pg_cron extension for local use, this is not available wihout installing
88-
# run this as a separate layer so it caches better
89-
RUN git clone --depth 1 https://github.com/citusdata/pg_cron.git /pg_cron && \
90-
cd /pg_cron && make && PATH=$PATH make install && \
91-
rm -rf /pg_cron
92-
9393
# Install pgTAP & pg_prove utility.
9494
RUN git clone --depth 1 -b "v$PGTAP_VERSION" https://github.com/theory/pgtap.git /pgtap && \
9595
cd /pgtap && make && make install && \

0 commit comments

Comments
 (0)