1
- ARG PG_SERVER_VERSION=12
1
+ ARG PG_SERVER_VERSION=11
2
2
3
3
FROM postgres:${PG_SERVER_VERSION}
4
4
LABEL maintainer="postgres.ai"
@@ -8,69 +8,92 @@ ARG PG_SERVER_VERSION
8
8
ENV PG_SERVER_VERSION=${PG_SERVER_VERSION:-12}
9
9
ENV CITUS_VERSION=9.4
10
10
11
- RUN apt-get update \
12
- && apt-get install --no-install-recommends -y wget make gcc unzip sudo git curl libc6-dev apt-transport-https ca-certificates pgxnclient build-essential libevent-dev \
13
- libssl-dev krb5-multidev \
14
- && apt-get install --no-install-recommends -y postgresql-server-dev-${PG_SERVER_VERSION} \
15
- && apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-repack \
16
- && apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-hypopg \
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" \
23
- # add timescaledb extension
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 \
25
- && wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo apt-key add - \
26
- && apt-get update \
27
- && apt-get install -y timescaledb-postgresql-${PG_SERVER_VERSION} \
28
- # add citus extension
29
- && if [ "${PG_SERVER_VERSION}" = "12" ] || [ "${PG_SERVER_VERSION}" = "11" ]; then \
30
- # only 11 and 12 versions are supported by citus
31
- curl -s https://install.citusdata.com/community/deb.sh | bash \
32
- && apt-get install -y postgresql-${PG_SERVER_VERSION}-citus-${CITUS_VERSION} \
33
- postgresql-${PG_SERVER_VERSION}-hll=2.14.citus-1 \
34
- postgresql-${PG_SERVER_VERSION}-topn=2.3.0; \
35
- fi \
36
- # add powa extension
37
- && apt-get install postgresql-${PG_SERVER_VERSION}-powa \
38
- # add pg_timetable extension
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 \
40
- # add pg_show_plans extension
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 \
42
- # add pg_cron extension
43
- && apt-get install -y postgresql-${PG_SERVER_VERSION}-cron \
44
- # add postgresql_anonymizer extension
45
- && pgxn install ddlx && pgxn install postgresql_anonymizer \
46
- # add pg_stat_kcache extension
47
- && apt-get install postgresql-${PG_SERVER_VERSION}-pg-stat-kcache \
48
- # add pg_qualstats extension
49
- && apt-get install postgresql-${PG_SERVER_VERSION}-pg-qualstats \
50
- # add pg_mon extension
51
- && git clone https://github.com/CyberDem0n/bg_mon.git && cd bg_mon && USE_PGXS=1 make && USE_PGXS=1 make install \
52
- # add pgextwlist extension
53
- && apt-get install postgresql-${PG_SERVER_VERSION}-pgextwlist \
54
- # add pg_auth_mon extension
55
- && git clone https://github.com/RafiaSabih/pg_auth_mon.git && cd pg_auth_mon && USE_PGXS=1 make && USE_PGXS=1 make install \
56
- # add set_user extension
57
- && git clone https://github.com/pgaudit/set_user.git && cd set_user && make USE_PGXS=1 && make USE_PGXS=1 install \
58
- # Reduce images size.
59
- && rm -rf /tmp/* \
60
- && 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 \
61
- libssl-dev krb5-multidev comerr-dev krb5-multidev libgssrpc4 libkadm5clnt-mit11 libkadm5srv-mit11 \
62
- && apt-get clean -y autoclean \
63
- && rm -rf /var/lib/apt/lists/* \
64
- # We don't want to use standard pgdata.
65
- && rm -rf /var/lib/postgresql/${PG_SERVER_VERSION}/
11
+ RUN apt-get clean && rm -rf /var/lib/apt/lists/partial \
12
+ && apt-get update -o Acquire::CompressionTypes::Order::=gz \
13
+ && apt-get install --no-install-recommends -y wget make gcc unzip sudo git \
14
+ curl libc6-dev apt-transport-https ca-certificates pgxnclient \
15
+ build-essential libevent-dev libssl-dev krb5-multidev \
16
+ && apt-get install --no-install-recommends -y \
17
+ postgresql-server-dev-${PG_SERVER_VERSION} \
18
+ && apt-get install --no-install-recommends -y \
19
+ postgresql-${PG_SERVER_VERSION}-repack \
20
+ && apt-get install --no-install-recommends -y \
21
+ postgresql-${PG_SERVER_VERSION}-hypopg \
22
+ && apt-get install --no-install-recommends -y \
23
+ postgresql-${PG_SERVER_VERSION}-hypopg-dbgsym \
24
+ # pg_hint_plan extension (convert versions with dot "9.6" to "96")
25
+ && export PG_PLAN_HINT_VERSION=$(echo $PG_SERVER_VERSION | sed 's/\. //' ) \
26
+ && wget --quiet -O /tmp/pg_hint_plan.zip \
27
+ https://github.com/ossc-db/pg_hint_plan/archive/PG${PG_PLAN_HINT_VERSION}.zip \
28
+ && unzip /tmp/pg_hint_plan.zip -d /tmp \
29
+ && cd /tmp/pg_hint_plan-PG${PG_PLAN_HINT_VERSION} \
30
+ && make && make install \
31
+ # timescaledb extension
32
+ && echo 'deb https://packagecloud.io/timescale/timescaledb/debian/' \
33
+ $(env -i bash -c '. /etc/os-release; echo ${VERSION_CODENAME}' ) \
34
+ 'main' > /etc/apt/sources.list.d/timescaledb.list \
35
+ && wget --quiet -O - \
36
+ https://packagecloud.io/timescale/timescaledb/gpgkey | sudo apt-key add - \
37
+ && apt-get update \
38
+ && apt-get install -y timescaledb-postgresql-${PG_SERVER_VERSION} \
39
+ # citus extension. 11 and 12 versions only are supported by citus
40
+ && if [ "${PG_SERVER_VERSION}" = "12" ] || [ "${PG_SERVER_VERSION}" = "11" ]; then \
41
+ # only 11 and 12 versions are supported by citus
42
+ curl -s https://install.citusdata.com/community/deb.sh | bash \
43
+ && apt-get install -y postgresql-${PG_SERVER_VERSION}-citus-${CITUS_VERSION} \
44
+ postgresql-${PG_SERVER_VERSION}-hll=2.14.citus-1 \
45
+ postgresql-${PG_SERVER_VERSION}-topn=2.3.0; \
46
+ fi \
47
+ # powa extension
48
+ && apt-get install postgresql-${PG_SERVER_VERSION}-powa \
49
+ # pg_timetable extension
50
+ && wget https://github.com/cybertec-postgresql/pg_timetable/releases/download/v2.3.0/pg_timetable_2.3.0_Linux_x86_64.deb \
51
+ && dpkg -i pg_timetable_2.3.0_Linux_x86_64.deb \
52
+ && rm -rf pg_timetable_2.3.0_Linux_x86_64.deb \
53
+ # pg_show_plans extension
54
+ && git clone https://github.com/cybertec-postgresql/pg_show_plans.git \
55
+ && cd pg_show_plans \
56
+ && export USE_PGXS=1 && make && make install && cd .. && rm -rf pg_show_plans \
57
+ # pg_cron extension
58
+ && apt-get install -y postgresql-${PG_SERVER_VERSION}-cron \
59
+ # postgresql_anonymizer extension
60
+ && pgxn install ddlx && pgxn install postgresql_anonymizer \
61
+ # pg_stat_kcache extension
62
+ && apt-get install postgresql-${PG_SERVER_VERSION}-pg-stat-kcache \
63
+ # add pg_qualstats extension
64
+ && apt-get install postgresql-${PG_SERVER_VERSION}-pg-qualstats \
65
+ # pg_mon extension
66
+ && git clone https://github.com/CyberDem0n/bg_mon.git && cd bg_mon \
67
+ && USE_PGXS=1 make && USE_PGXS=1 make install \
68
+ # pgextwlist extension
69
+ && apt-get install postgresql-${PG_SERVER_VERSION}-pgextwlist \
70
+ # pg_auth_mon extension
71
+ && git clone https://github.com/RafiaSabih/pg_auth_mon.git \
72
+ && cd pg_auth_mon && USE_PGXS=1 make && USE_PGXS=1 make install \
73
+ # set_user extension
74
+ && git clone https://github.com/pgaudit/set_user.git \
75
+ && cd set_user && make USE_PGXS=1 && make USE_PGXS=1 install \
76
+ # remove all auxilary packages to reduce final image size
77
+ && cd / && rm -rf /tmp/* && apt-get purge -y --auto-remove gcc \
78
+ make wget unzip curl libc6-dev apt-transport-https git \
79
+ postgresql-server-dev-${PG_SERVER_VERSION} pgxnclient build-essential \
80
+ libssl-dev krb5-multidev comerr-dev krb5-multidev \
81
+ libgssrpc4 libkadm5clnt-mit11 libkadm5srv-mit11 \
82
+ && apt-get clean -y autoclean \
83
+ && rm -rf /var/lib/apt/lists/* \
84
+ # remove standard pgdata
85
+ && rm -rf /var/lib/postgresql/${PG_SERVER_VERSION}/
66
86
67
87
EXPOSE 5432
68
88
69
89
# Prepare Postgres start script.
70
90
RUN echo "#!/bin/bash" > /pg_start.sh && chmod a+x /pg_start.sh \
71
- && echo "chown -R postgres:postgres /var/lib/postgresql/pgdata /var/run/postgresql" >> /pg_start.sh \
72
- && printf "sudo -u postgres /usr/lib/postgresql/${PG_SERVER_VERSION}/bin/postgres -D /var/lib/postgresql/pgdata \n " >> /pg_start.sh \
91
+ && echo "chown -R postgres:postgres /var/lib/postgresql/pgdata /var/run/postgresql" \
92
+ >> /pg_start.sh \
93
+ && printf "sudo -u postgres /usr/lib/postgresql/${PG_SERVER_VERSION}/bin/postgres -D /var/lib/postgresql/pgdata \n " \
94
+ >> /pg_start.sh \
73
95
# Infinite sleep to allow restarting Postgres.
74
- && echo "/bin/bash -c \" trap : TERM INT; sleep infinity & wait\" " >> /pg_start.sh
96
+ && echo "/bin/bash -c \" trap : TERM INT; sleep infinity & wait\" " \
97
+ >> /pg_start.sh
75
98
76
99
CMD ["/pg_start.sh" ]
0 commit comments