1- FROM ubuntu:16 .04
1+ FROM ubuntu:18 .04
22
33ARG PG_SERVER_VERSION
44
5- ENV PG_SERVER_VERSION=${PG_SERVER_VERSION:-11 } \
5+ ENV PG_SERVER_VERSION=${PG_SERVER_VERSION:-12 } \
66 DEBIAN_FRONTEND=noninteractive
77
88# add custom FTS dictionaries
9- ADD ./tsearch_data /usr/share/postgresql/$PG_SERVER_VERSION/tsearch_data
9+ ADD ./tsearch_data /usr/share/postgresql/${ PG_SERVER_VERSION} /tsearch_data
1010
1111# logging ON; memory setting – for 2CPU/4096MB/SSD
1212ADD ./postgresql_${PG_SERVER_VERSION}_tweak.conf /postgresql.tweak.conf
1313
1414# set up apt, add Postgres repo
1515RUN apt-get update
16- RUN apt-get install -y wget ca-certificates
16+ RUN apt-get install -y wget ca-certificates gnupg2
1717RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
18- RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial -pgdg main $PG_SERVER_VERSION" > /etc/apt/sources.list.d/pgdg.list
18+ RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bionic -pgdg main" > > /etc/apt/sources.list.d/pgdg.list
1919RUN apt-get update
2020RUN apt-get install -y apt-utils
2121
2222# install additional utilites
2323RUN apt-get install -y sudo git jq libjson-xs-perl vim
24- RUN apt-get install -y sysbench s3cmd sudo bzip2 python-software-properties software-properties-common
24+ RUN apt-get install -y sysbench s3cmd sudo bzip2 software-properties-common
2525RUN apt-get install -y sysstat iotop moreutils psmisc
2626
2727# install Postgres and postgres-specific packages
28- RUN apt-get install -y postgresql-$PG_SERVER_VERSION
29- RUN apt-get install -y postgresql-contrib-$PG_SERVER_VERSION
30- RUN apt-get install -y postgresql-plpython-$PG_SERVER_VERSION
31- RUN apt-get install -y postgresql-server-dev-$PG_SERVER_VERSION
32- RUN apt-get install -y postgresql-$PG_SERVER_VERSION-dbg
33- RUN apt-get install -y postgresql-$PG_SERVER_VERSION-pg-stat-kcache
34- RUN apt-get install -y postgresql-client-11
28+ RUN apt-get install -y postgresql-${PG_SERVER_VERSION}
29+ RUN apt-get install -y postgresql-contrib-${PG_SERVER_VERSION}
30+ RUN apt-get install -y postgresql-server-dev-${PG_SERVER_VERSION}
31+ # RUN if [ "${PG_SERVER_VERSION}" != "12" ]; then apt-get install -y postgresql-${PG_SERVER_VERSION}-dbg; fi
32+ RUN apt-get install -y postgresql-${PG_SERVER_VERSION}-pg-stat-kcache
33+ RUN apt-get install -y postgresql-client-12
34+ RUN if [ "${PG_SERVER_VERSION}" == "12" ]; then apt-get install -y postgresql-plpython3-${PG_SERVER_VERSION}; fi
35+ RUN if [ "${PG_SERVER_VERSION}" != "12" ]; then apt-get install -y postgresql-plpython-${PG_SERVER_VERSION}; fi
3536
3637RUN apt-get install -y pgreplay
37- RUN apt-get install -y pspg
38+ RUN apt-get update && apt-get install -y pspg
3839RUN git clone https://github.com/NikolayS/postgres_dba.git /root/postgres_dba
39- RUN apt-get install -y postgresql-$PG_SERVER_VERSION-repack
40- RUN git clone https://github.com/darold/pgbadger.git /root/pgbadger && cd /root/pgbadger && git checkout "tags/v10.3 "
40+ RUN apt-get install -y postgresql-${ PG_SERVER_VERSION} -repack
41+ RUN git clone https://github.com/darold/pgbadger.git /root/pgbadger && cd /root/pgbadger && git checkout "tags/v11.1 "
4142
4243# install FlameGraph and generic perf
4344RUN git clone https://github.com/brendangregg/FlameGraph /root/FlameGraph
@@ -48,30 +49,30 @@ RUN path=$(ls /usr/lib/linux-tools/*generic/perf | head -n 1) && ln -s -f "$path
4849# configure psql, configure Postgres
4950RUN echo "\\ set dba '\\\\\\\\ i /root/postgres_dba/start.psql'" >> ~/.psqlrc
5051RUN echo "\\ setenv PAGER 'pspg -bX --no-mouse'" >> ~/.psqlrc
51- RUN echo "local all all trust" > /etc/postgresql/$PG_SERVER_VERSION/main/pg_hba.conf
52- RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/$PG_SERVER_VERSION/main/pg_hba.conf
53- RUN echo "listen_addresses='*'" >> /etc/postgresql/$PG_SERVER_VERSION/main/postgresql.conf
54- RUN echo "log_filename='postgresql-$PG_SERVER_VERSION-main.log'" >> /etc/postgresql/$PG_SERVER_VERSION/main/postgresql.conf
52+ RUN echo "local all all trust" > /etc/postgresql/${ PG_SERVER_VERSION} /main/pg_hba.conf
53+ RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/${ PG_SERVER_VERSION} /main/pg_hba.conf
54+ RUN echo "listen_addresses='*'" >> /etc/postgresql/${ PG_SERVER_VERSION} /main/postgresql.conf
55+ RUN echo "log_filename='postgresql-${ PG_SERVER_VERSION} -main.log'" >> /etc/postgresql/${ PG_SERVER_VERSION} /main/postgresql.conf
5556
5657# prepare database 'test' with 'testuser'
5758RUN /etc/init.d/postgresql start && psql -U postgres -c "create database test" \
5859 && psql -U postgres -d test -c "CREATE EXTENSION pg_repack" \
5960 && psql -U postgres -c "CREATE ROLE testuser LOGIN password 'testuser' superuser" && /etc/init.d/postgresql stop
6061
6162# apply 'tweaked' config
62- RUN cat /postgresql.tweak.conf >> /etc/postgresql/$PG_SERVER_VERSION/main/postgresql.conf
63+ RUN cat /postgresql.tweak.conf >> /etc/postgresql/${ PG_SERVER_VERSION} /main/postgresql.conf
6364
6465# prepare Postgres start script
6566RUN echo "#!/bin/bash" > /pg_start.sh && chmod a+x /pg_start.sh
66- RUN printf "sudo -u postgres /usr/lib/postgresql/$PG_SERVER_VERSION/bin/postgres -D /var/lib/postgresql/$PG_SERVER_VERSION/main -c config_file=/etc/postgresql/$PG_SERVER_VERSION/main/postgresql.conf \n " >> /pg_start.sh
67+ RUN printf "sudo -u postgres /usr/lib/postgresql/${ PG_SERVER_VERSION} /bin/postgres -D /var/lib/postgresql/${ PG_SERVER_VERSION} /main -c config_file=/etc/postgresql/${ PG_SERVER_VERSION} /main/postgresql.conf \n " >> /pg_start.sh
6768# infinite sleep to allow restarting Postgres
6869RUN echo "/bin/bash -c \" trap : TERM INT; sleep infinity & wait\" " >> /pg_start.sh
6970
7071# generate english locale for iostat + iostat-tool
7172RUN locale-gen en_US.UTF-8
7273
7374# install pip and iostat-tool
74- RUN apt-get install curl
75+ RUN apt-get install -y curl
7576RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
7677RUN python3 get-pip.py
7778RUN pip3 install iostat-tool
0 commit comments