Skip to content

Commit 1c4a8f6

Browse files
committed
reduce image size
1 parent 24417d2 commit 1c4a8f6

File tree

1 file changed

+24
-54
lines changed

1 file changed

+24
-54
lines changed

extended/Dockerfile

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
ARG PG_SERVER_VERSION=11
2-
ARG CITUS=9.4
1+
ARG PG_SERVER_VERSION=12
32

43
FROM postgres:${PG_SERVER_VERSION}
54
MAINTAINER postgres.ai
@@ -15,82 +14,53 @@ RUN apt-get update \
1514
&& apt-get install --no-install-recommends -y postgresql-server-dev-${PG_SERVER_VERSION} \
1615
&& apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-repack \
1716
&& apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-hypopg \
18-
&& apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-hypopg-dbgsym
19-
20-
RUN if [ "${PG_SERVER_VERSION}" = "12" ]; then \
21-
# pg_hint_plan for Postgres 12 does not supported yet, use master: https://github.com/ossc-db/pg_hint_plan/issues/37
22-
wget --quiet -O /tmp/pg_hint_plan.zip https://github.com/ossc-db/pg_hint_plan/archive/master.zip \
23-
&& unzip /tmp/pg_hint_plan.zip -d /tmp && cd /tmp/pg_hint_plan-master \
24-
&& make && make install || echo "[WARNING] pg_hint_plan extension not found"; \
25-
else \
26-
# convert versions with dot "9.6" to "96"
27-
export PG_PLAN_HINT_VERSION=$(echo $PG_SERVER_VERSION | sed 's/\.//') \
28-
&& wget --quiet -O /tmp/pg_hint_plan.zip https://github.com/ossc-db/pg_hint_plan/archive/PG${PG_PLAN_HINT_VERSION}.zip \
29-
&& unzip /tmp/pg_hint_plan.zip -d /tmp && cd /tmp/pg_hint_plan-PG${PG_PLAN_HINT_VERSION} \
30-
&& make && make install || echo "[WARNING] pg_hint_plan extension not found"; \
31-
fi
32-
17+
&& apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-hypopg-dbgsym \
18+
# convert versions with dot "9.6" to "96"
19+
&& export PG_PLAN_HINT_VERSION=$(echo $PG_SERVER_VERSION | sed 's/\.//') \
20+
&& wget --quiet -O /tmp/pg_hint_plan.zip https://github.com/ossc-db/pg_hint_plan/archive/PG${PG_PLAN_HINT_VERSION}.zip \
21+
&& unzip /tmp/pg_hint_plan.zip -d /tmp && cd /tmp/pg_hint_plan-PG${PG_PLAN_HINT_VERSION} \
22+
&& make && make install || echo "[WARNING] pg_hint_plan extension not found" \
3323
# add timescaledb extension
34-
RUN echo 'deb https://packagecloud.io/timescale/timescaledb/debian/' `env -i bash -c '. /etc/os-release; echo $VERSION_CODENAME'` 'main' > /etc/apt/sources.list.d/timescaledb.list \
24+
&& echo 'deb https://packagecloud.io/timescale/timescaledb/debian/' `env -i bash -c '. /etc/os-release; echo $VERSION_CODENAME'` 'main' > /etc/apt/sources.list.d/timescaledb.list \
3525
&& wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo apt-key add - \
3626
&& apt-get update \
37-
&& apt-get install -y timescaledb-postgresql-${PG_SERVER_VERSION}
38-
39-
27+
&& apt-get install -y timescaledb-postgresql-${PG_SERVER_VERSION} \
4028
# add citus extension
41-
RUN if [ "${PG_SERVER_VERSION}" = "12" ] || [ "${PG_SERVER_VERSION}" = "11" ]; then \
29+
&& if [ "${PG_SERVER_VERSION}" = "12" ] || [ "${PG_SERVER_VERSION}" = "11" ]; then \
4230
# only 11 and 12 versions are supported by citus
4331
curl -s https://install.citusdata.com/community/deb.sh | bash \
4432
&& apt-get install -y postgresql-${PG_SERVER_VERSION}-citus-${CITUS_VERSION} \
4533
postgresql-${PG_SERVER_VERSION}-hll=2.14.citus-1 \
4634
postgresql-${PG_SERVER_VERSION}-topn=2.3.0; \
47-
fi
35+
fi \
4836
# add powa extension
49-
RUN apt-get install postgresql-${PG_SERVER_VERSION}-powa
50-
37+
&& apt-get install postgresql-${PG_SERVER_VERSION}-powa \
5138
# add pg_timetable extension
52-
RUN wget https://github.com/cybertec-postgresql/pg_timetable/releases/download/v2.3.0/pg_timetable_2.3.0_Linux_x86_64.deb \
53-
&& dpkg -i pg_timetable_2.3.0_Linux_x86_64.deb \
54-
&& rm -rf pg_timetable_2.3.0_Linux_x86_64.deb
55-
39+
&& wget https://github.com/cybertec-postgresql/pg_timetable/releases/download/v2.3.0/pg_timetable_2.3.0_Linux_x86_64.deb && dpkg -i pg_timetable_2.3.0_Linux_x86_64.deb && rm -rf pg_timetable_2.3.0_Linux_x86_64.deb \
5640
# add pg_show_plans extension
57-
RUN git clone https://github.com/cybertec-postgresql/pg_show_plans.git
58-
WORKDIR /pg_show_plans
59-
RUN export USE_PGXS=1 && make && make install
60-
WORKDIR /
61-
41+
&& git clone https://github.com/cybertec-postgresql/pg_show_plans.git && cd pg_show_plans && export USE_PGXS=1 && make && make install && cd .. && rm -rf pg_show_plans \
6242
# add pg_cron extension
63-
RUN apt-get install -y postgresql-${PG_SERVER_VERSION}-cron
64-
43+
&& apt-get install -y postgresql-${PG_SERVER_VERSION}-cron \
6544
# add postgresql_anonymizer extension
66-
RUN pgxn install ddlx && pgxn install postgresql_anonymizer
67-
68-
45+
&& pgxn install ddlx && pgxn install postgresql_anonymizer \
6946
# add pg_stat_kcache extension
70-
RUN apt-get install postgresql-${PG_SERVER_VERSION}-pg-stat-kcache
71-
47+
&& apt-get install postgresql-${PG_SERVER_VERSION}-pg-stat-kcache \
7248
# add pg_qualstats extension
73-
RUN apt-get install postgresql-${PG_SERVER_VERSION}-pg-qualstats
74-
49+
&&apt-get install postgresql-${PG_SERVER_VERSION}-pg-qualstats \
7550
#add pg_mon extension
76-
RUN git clone https://github.com/CyberDem0n/bg_mon.git && cd bg_mon && USE_PGXS=1 make && USE_PGXS=1 make install
77-
51+
&& git clone https://github.com/CyberDem0n/bg_mon.git && cd bg_mon && USE_PGXS=1 make && USE_PGXS=1 make install \
7852
# add pgextwlist extension
79-
RUN apt-get install postgresql-${PG_SERVER_VERSION}-pgextwlist
80-
53+
&& apt-get install postgresql-${PG_SERVER_VERSION}-pgextwlist \
8154
# add pg_auth_mon extension
82-
RUN git clone https://github.com/RafiaSabih/pg_auth_mon.git && cd pg_auth_mon && USE_PGXS=1 make && USE_PGXS=1 make install
83-
55+
&& git clone https://github.com/RafiaSabih/pg_auth_mon.git && cd pg_auth_mon && USE_PGXS=1 make && USE_PGXS=1 make install \
8456
# add set_user extension
85-
RUN git clone https://github.com/pgaudit/set_user.git && cd set_user && make USE_PGXS=1 && make USE_PGXS=1 install
86-
57+
&& git clone https://github.com/pgaudit/set_user.git && cd set_user && make USE_PGXS=1 && make USE_PGXS=1 install \
8758
# Reduce images size.
88-
RUN rm -rf /tmp/* \
59+
&& rm -rf /tmp/* \
8960
&& apt-get purge -y --auto-remove gcc make wget unzip curl libc6-dev apt-transport-https git postgresql-server-dev-${PG_SERVER_VERSION} pgxnclient build-essential libevent-dev \
90-
libssl-dev krb5-multidev comerr-dev krb5-multidev libgssrpc4 libkadm5clnt-mit11 libkadm5srv-mit11 \
61+
libssl-dev krb5-multidev comerr-dev krb5-multidev libgssrpc4 libkadm5clnt-mit11 libkadm5srv-mit11 \
9162
&& apt-get clean -y autoclean \
9263
&& rm -rf /var/lib/apt/lists/* \
93-
&& rm -rf /pg_show_plans \
9464
# We don't want to use standard pgdata.
9565
&& rm -rf /var/lib/postgresql/${PG_SERVER_VERSION}/
9666

0 commit comments

Comments
 (0)