Skip to content

Commit ee467bb

Browse files
author
Sameer Naik
committed
optimize image size with multistage builds
1 parent 50c3c7c commit ee467bb

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Dockerfile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1+
FROM ubuntu:bionic-20180526 AS add-apt-repositories
2+
3+
RUN apt-get update \
4+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y wget gnupg \
5+
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
6+
&& echo 'deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main' >> /etc/apt/sources.list
7+
18
FROM ubuntu:bionic-20180526
9+
210
LABEL maintainer="[email protected]"
311

412
ENV PG_APP_HOME="/etc/docker-postgresql" \
@@ -12,11 +20,11 @@ ENV PG_APP_HOME="/etc/docker-postgresql" \
1220
ENV PG_BINDIR=/usr/lib/postgresql/${PG_VERSION}/bin \
1321
PG_DATADIR=${PG_HOME}/${PG_VERSION}/main
1422

23+
COPY --from=add-apt-repositories /etc/apt/trusted.gpg /etc/apt/trusted.gpg
24+
25+
COPY --from=add-apt-repositories /etc/apt/sources.list /etc/apt/sources.list
26+
1527
RUN apt-get update \
16-
&& DEBIAN_FRONTEND=noninteractive apt-get install -y wget gnupg \
17-
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
18-
&& echo 'deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main' > /etc/apt/sources.list.d/pgdg.list \
19-
&& apt-get update \
2028
&& DEBIAN_FRONTEND=noninteractive apt-get install -y acl sudo \
2129
postgresql-${PG_VERSION} postgresql-client-${PG_VERSION} postgresql-contrib-${PG_VERSION} \
2230
&& ln -sf ${PG_DATADIR}/postgresql.conf /etc/postgresql/${PG_VERSION}/main/postgresql.conf \
@@ -26,9 +34,13 @@ RUN apt-get update \
2634
&& rm -rf /var/lib/apt/lists/*
2735

2836
COPY runtime/ ${PG_APP_HOME}/
37+
2938
COPY entrypoint.sh /sbin/entrypoint.sh
39+
3040
RUN chmod 755 /sbin/entrypoint.sh
3141

3242
EXPOSE 5432/tcp
43+
3344
WORKDIR ${PG_HOME}
45+
3446
ENTRYPOINT ["/sbin/entrypoint.sh"]

0 commit comments

Comments
 (0)