Skip to content

Commit 925bfc2

Browse files
committed
Initial contents
1 parent 700b728 commit 925bfc2

31 files changed

+3291
-1
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
docker-context
2+
private*.xml
3+
benchmark-results*
4+
*.tar.gz
5+
*.git
6+
resources/
7+
scripts/soft-reset
8+
!scripts/soft-reset.c

Dockerfile-pgapt

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
FROM ubuntu
2+
ARG PG_VERSION
3+
ARG PHASE1_ACTION
4+
ARG PHASE2_ACTION
5+
ARG REPOSITORY
6+
ARG EXTRA_OS_PACKAGES
7+
ARG EXTRA_PG_MODULES
8+
ARG PG_PARAMETERS
9+
ARG CFG_OPTIONS
10+
11+
ENV DEBIAN_FRONTEND=noninteractive
12+
13+
# Install a common set of packages needed for tests
14+
# There are some warnings (in red) that show up during the build. You can hide
15+
# them by prefixing each apt statement with DEBIAN_FRONTEND=noninteractive
16+
RUN p=$EXTRA_OS_PACKAGES; p="${p%\"}";p="${p#\"}"; \
17+
apt update && apt install -y $p python3 python3-dev python3-pip \
18+
software-properties-common wget vim time pkg-config locales recode \
19+
git gcc make libreadline-dev zlib1g-dev libicu-dev bison flex gettext \
20+
openjdk-17-jdk maven
21+
22+
RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
23+
ENV LANG en_US.UTF-8
24+
ENV LC_ALL en_US.UTF-8
25+
26+
COPY ./$PHASE1_ACTION /bin/
27+
RUN $PHASE1_ACTION
28+
29+
# Add the PostgreSQL PGP key to verify their Debian packages.
30+
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
31+
32+
# Add PostgreSQL's repository.
33+
RUN echo "deb $REPOSITORY" | sed s/\$OS_CODENAME/$(lsb_release -cs)/ > /etc/apt/sources.list.d/pgrepo.list
34+
35+
# Install PostgreSQL
36+
# There are some warnings (in red) that show up during the build. You can hide
37+
# them by prefixing each apt statement with DEBIAN_FRONTEND=noninteractive
38+
RUN apt-get update && apt-get install -y -t `awk '{print $3}' /etc/apt/sources.list.d/pgrepo.list` \
39+
postgresql-$PG_VERSION postgresql-client-$PG_VERSION postgresql-contrib-$PG_VERSION
40+
41+
WORKDIR /home/postgres
42+
43+
ADD postgres-pgbench.tar.gz /home/postgres/src/postgres-pgbench
44+
RUN chown -R postgres:postgres /home/postgres/
45+
46+
# Setup jdbc driver
47+
RUN JAVA_VERSION=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}'); \
48+
case "$JAVA_VERSION" in \
49+
1\.6* ) jdbcjar="https://jdbc.postgresql.org/download/postgresql-42.2.12.jre6.jar" ;; \
50+
1\.7* ) jdbcjar="https://jdbc.postgresql.org/download/postgresql-42.2.12.jre7.jar" ;; \
51+
*) jdbcjar="https://jdbc.postgresql.org/download/postgresql-42.2.12.jar" ;; \
52+
esac; \
53+
[ -z "$jdbcjar" ] || wget --no-verbose "$jdbcjar" -P /usr/share/java
54+
55+
RUN pg_dropcluster --stop $PG_VERSION main
56+
57+
COPY ./$PHASE2_ACTION /bin/
58+
RUN $PHASE2_ACTION
59+
60+
RUN pg_createcluster --start $PG_VERSION main
61+
62+
RUN touch /home/postgres/extra.conf && printf "\nlisten_addresses='*'\n"\
63+
"logging_collector = on\n"\
64+
"fsync = off\n"\
65+
"max_connections = 500\n"\
66+
"include '/home/postgres/extra.conf'\n" >> /etc/postgresql/$PG_VERSION/main/postgresql.conf
67+
RUN m=$EXTRA_PG_MODULES; m="${m%\"}";m="${m#\"}"; \
68+
[ ! -z "$m" ] || printf "\nshared_preload_libraries = '"$m"'\n" >> /etc/postgresql/$PG_VERSION/main/postgresql.conf
69+
RUN p=$PG_PARAMETERS; p="${p%\"}"; p="${p#\"}"; \
70+
[ -z "$p" ] || printf "\n$p\n" >> /etc/postgresql/$PG_VERSION/main/postgresql.conf
71+
72+
RUN sed -i -e 's/^\(host\s\+all\s\+all\s\+127\.0\.0\.1\/32\)/#\1/' \
73+
-e 's/^\(host\s\+all\s\+all\s\+::1\/128\)/#\1/' /etc/postgresql/$PG_VERSION/main/pg_hba.conf; \
74+
printf "\n"\
75+
"host all all 127.0.0.1/32 trust\n"\
76+
"host all all 0.0.0.0/0 md5\n"\
77+
"host all all ::1/128 trust\n" >> /etc/postgresql/$PG_VERSION/main/pg_hba.conf
78+
79+
RUN echo "/usr/lib/postgresql/$PG_VERSION/bin/postgres -D /var/lib/postgresql/$PG_VERSION/main -c config_file=/etc/postgresql/$PG_VERSION/main/postgresql.conf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain
80+
81+
# Run the rest of the commands as the ``postgres`` user created by the ``postgres-$version`` package when it was ``apt installed``
82+
USER postgres
83+
84+
RUN pg_ctlcluster $PG_VERSION main start -- -w && \
85+
psql -c "CREATE USER tester WITH SUPERUSER PASSWORD 'tester'; ALTER user postgres password 'pgpass';"
86+
87+
COPY ./setup-reference-pgbench /tmp/
88+
RUN /tmp/setup-reference-pgbench $PG_VERSION
89+
90+
# Expose the PostgreSQL port
91+
EXPOSE 5432
92+
93+
# Add VOLUMEs to allow backup of config, logs and databases
94+
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
95+
96+
# Set the default command to run when starting the container
97+
CMD /usr/bin/pgmain

Dockerfile-proapt

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
FROM ubuntu
2+
ARG PG_VERSION
3+
ARG PHASE1_ACTION
4+
ARG PHASE2_ACTION
5+
ARG REPOSITORY
6+
ARG EXTRA_OS_PACKAGES
7+
ARG EXTRA_PG_MODULES
8+
ARG PG_PARAMETERS
9+
ARG CFG_OPTIONS
10+
11+
ARG PGPRO_EDN
12+
13+
ENV DEBIAN_FRONTEND=noninteractive
14+
15+
# Install a common set of packages needed for tests
16+
# There are some warnings (in red) that show up during the build. You can hide
17+
# them by prefixing each apt statement with DEBIAN_FRONTEND=noninteractive
18+
RUN p=$EXTRA_OS_PACKAGES; p="${p%\"}";p="${p#\"}"; \
19+
apt update && apt install -y $p python3 python3-dev python3-pip \
20+
software-properties-common wget vim time pkg-config locales recode \
21+
git gcc make libreadline-dev zlib1g-dev libicu-dev bison flex gettext \
22+
openjdk-17-jdk maven
23+
24+
RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
25+
ENV LANG en_US.UTF-8
26+
ENV LC_ALL en_US.UTF-8
27+
28+
COPY ./$PHASE1_ACTION /bin/
29+
RUN $PHASE1_ACTION
30+
31+
RUN echo $REPOSITORY
32+
RUN echo `echo $REPOSITORY | sed 's|^\([^/]*//[^/]*/[^/]*\).*|\1|'`
33+
34+
# Add the Postgres PRO PGP key to verify the Debian packages.
35+
# http://repo.postgrespro.ru/std-15/ubuntu $OS_CODENAME main -> http://repo.postgrespro.ru/std-$PG_VERSION/keys/GPG-KEY-POSTGRESPRO
36+
RUN wget --quiet -O - `echo $REPOSITORY | sed 's|^\([^/]*//[^/]*/[^/]*\).*|\1|'`/keys/GPG-KEY-POSTGRESPRO | apt-key add -
37+
38+
# Add Postgres Pro's repository.
39+
RUN echo "deb $REPOSITORY" | sed s/\$OS_CODENAME/$(lsb_release -cs)/ > /etc/apt/sources.list.d/postgrespro.list
40+
41+
# Install Postgres Pro
42+
# There are some warnings (in red) that show up during the build. You can hide
43+
# them by prefixing each apt statement with DEBIAN_FRONTEND=noninteractive
44+
RUN apt-get update && apt-get install -y postgrespro-$PGPRO_EDN-$PG_VERSION postgrespro-$PGPRO_EDN-$PG_VERSION-server postgrespro-$PGPRO_EDN-$PG_VERSION-contrib
45+
46+
WORKDIR /home/postgres
47+
48+
ADD postgres-pgbench.tar.gz /home/postgres/src/postgres-pgbench
49+
RUN chown -R postgres:postgres /home/postgres/
50+
51+
# Setup jdbc driver
52+
RUN JAVA_VERSION=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}'); \
53+
case "$JAVA_VERSION" in \
54+
1\.6* ) jdbcjar="https://jdbc.postgresql.org/download/postgresql-42.2.12.jre6.jar" ;; \
55+
1\.7* ) jdbcjar="https://jdbc.postgresql.org/download/postgresql-42.2.12.jre7.jar" ;; \
56+
*) jdbcjar="https://jdbc.postgresql.org/download/postgresql-42.2.12.jar" ;; \
57+
esac; \
58+
[ -z "$jdbcjar" ] || wget --no-verbose "$jdbcjar" -P /usr/share/java
59+
60+
RUN rm -rf /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data
61+
62+
RUN /opt/pgpro/$PGPRO_EDN-$PG_VERSION/bin/pg-setup initdb
63+
64+
COPY ./$PHASE2_ACTION /bin/
65+
RUN $PHASE2_ACTION
66+
67+
RUN touch /home/postgres/extra.conf && printf "\nlisten_addresses='*'\n"\
68+
"logging_collector = on\n"\
69+
"fsync = off\n"\
70+
"max_connections = 500\n"\
71+
"include '/home/postgres/extra.conf'\n" >> /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data/postgresql.conf
72+
RUN m=$EXTRA_PG_MODULES; m="${m%\"}";m="${m#\"}"; \
73+
[ ! -z "$m" ] || printf "\nshared_preload_libraries = '"$m"'\n" >> /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data/postgresql.conf
74+
RUN p=$PG_PARAMETERS; p="${p%\"}"; p="${p#\"}"; \
75+
[ -z "$p" ] || printf "\n$p\n" >> /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data/postgresql.conf
76+
77+
RUN sed -i -e 's/^\(host\s\+all\s\+all\s\+127\.0\.0\.1\/32\)/#\1/' \
78+
-e 's/^\(host\s\+all\s\+all\s\+::1\/128\)/#\1/' /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data/pg_hba.conf; \
79+
printf "\n"\
80+
"host all all 127.0.0.1/32 trust\n"\
81+
"host all all 0.0.0.0/0 md5\n"\
82+
"host all all ::1/128 trust\n" >> /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data/pg_hba.conf
83+
84+
RUN echo "/opt/pgpro/$PGPRO_EDN-$PG_VERSION/bin/postgres -D /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data -c config_file=/var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data/postgresql.conf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain
85+
86+
# Run the rest of the commands as the ``postgres`` user created by the ``postgres*-$version`` package when it was ``apt installed``
87+
USER postgres
88+
89+
RUN /opt/pgpro/$PGPRO_EDN-$PG_VERSION/bin/pg_ctl start -D /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data -w && \
90+
psql -c "CREATE USER tester WITH SUPERUSER PASSWORD 'tester'; ALTER user postgres password 'pgpass';"
91+
92+
COPY ./setup-reference-pgbench /tmp/
93+
RUN /tmp/setup-reference-pgbench $PG_VERSION
94+
95+
# Expose the PostgreSQL port
96+
EXPOSE 5432
97+
98+
# Add VOLUMEs to allow backup of config, logs and databases
99+
VOLUME ["/var/lib/pgpro"]
100+
101+
# Set the default command to run when starting the container
102+
CMD /usr/bin/pgmain

Dockerfile-src

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
FROM ubuntu
2+
ARG PG_VERSION
3+
ARG PHASE1_ACTION
4+
ARG PHASE2_ACTION
5+
ARG REPOSITORY
6+
ARG EXTRA_OS_PACKAGES
7+
ARG EXTRA_SRC_GIT
8+
ARG EXTRA_PG_MODULES
9+
ARG PG_PARAMETERS
10+
ARG CFG_OPTIONS
11+
12+
ENV DEBIAN_FRONTEND=noninteractive
13+
14+
# Install a common set of packages needed for tests
15+
# There are some warnings (in red) that show up during the build. You can hide
16+
# them by prefixing each apt statement with DEBIAN_FRONTEND=noninteractive
17+
RUN p=$EXTRA_OS_PACKAGES; p="${p%\"}";p="${p#\"}"; \
18+
apt update && apt install -y $p python3 python3-dev python3-pip \
19+
software-properties-common wget vim time pkg-config locales recode \
20+
git gcc make libreadline-dev zlib1g-dev libicu-dev bison flex gettext \
21+
openjdk-17-jdk maven
22+
23+
RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
24+
ENV LANG en_US.UTF-8
25+
ENV LC_ALL en_US.UTF-8
26+
27+
COPY ./$PHASE1_ACTION /bin/
28+
RUN $PHASE1_ACTION
29+
30+
RUN useradd -m postgres
31+
32+
WORKDIR /home/postgres
33+
34+
ADD postgres.tar.gz /home/postgres/src/postgres
35+
ADD postgres-pgbench.tar.gz /home/postgres/src/postgres-pgbench
36+
RUN chown -R postgres:postgres /home/postgres/
37+
38+
# Setup jdbc driver
39+
RUN JAVA_VERSION=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}'); \
40+
case "$JAVA_VERSION" in \
41+
1\.6* ) jdbcjar="https://jdbc.postgresql.org/download/postgresql-42.2.12.jre6.jar" ;; \
42+
1\.7* ) jdbcjar="https://jdbc.postgresql.org/download/postgresql-42.2.12.jre7.jar" ;; \
43+
*) jdbcjar="https://jdbc.postgresql.org/download/postgresql-42.2.12.jar" ;; \
44+
esac; \
45+
[ -z "$jdbcjar" ] || wget --no-verbose "$jdbcjar" -P /usr/share/java
46+
47+
USER postgres
48+
49+
RUN o=$CFG_OPTIONS; o="${o%\"}";o="${o#\"}"; \
50+
cd ~/src/postgres && ./configure -q $o && \
51+
make -s -j8 && make -s -j8 -C contrib
52+
53+
USER root
54+
55+
RUN cd /home/postgres/src/postgres && make -s install && \
56+
make -s install -C contrib && \
57+
mkdir -p /var/lib/postgresql/main && chown -R postgres:postgres /var/lib/postgresql
58+
59+
ENV PATH "$PATH:/usr/local/pgsql/bin"
60+
61+
RUN echo "/usr/local/pgsql/bin/postgres -D /var/lib/postgresql/main -c config_file=/var/lib/postgresql/main/postgresql.conf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain
62+
63+
COPY ./$PHASE2_ACTION /bin/
64+
RUN $PHASE2_ACTION
65+
66+
# Build and install extra module if needed
67+
USER postgres
68+
69+
RUN if [ ! -z "$EXTRA_SRC_GIT" ]; then \
70+
mkdir -p /home/postgres/src && cd /home/postgres/src && git clone --depth 1 $EXTRA_SRC_GIT extra && \
71+
cd extra && make USE_PGXS=1; \
72+
fi
73+
74+
USER root
75+
76+
RUN if [ -d /home/postgres/src/extra ]; then cd /home/postgres/src/extra && make install USE_PGXS=1; fi
77+
78+
USER postgres
79+
80+
RUN /usr/local/pgsql/bin/initdb -D /var/lib/postgresql/main -k
81+
82+
RUN touch /home/postgres/extra.conf && printf "\nlisten_addresses='*'\n"\
83+
"logging_collector = on\n"\
84+
"fsync = off\n"\
85+
"max_connections = 500\n"\
86+
"include '/home/postgres/extra.conf'\n" >> /var/lib/postgresql/main/postgresql.conf
87+
# log_statement = all
88+
# log_min_messages = info
89+
RUN m=$EXTRA_PG_MODULES; m="${m%\"}";m="${m#\"}"; \
90+
[ ! -z "$m" ] || printf "\nshared_preload_libraries = '"$m"'\n" >> /var/lib/postgresql/main/postgresql.conf
91+
RUN p=$PG_PARAMETERS; p="${p%\"}"; p="${p#\"}"; \
92+
[ -z "$p" ] || printf "\n$p\n" >> /var/lib/postgresql/main/postgresql.conf
93+
94+
RUN printf "\n"\
95+
"host all all 127.0.0.1/32 trust\n"\
96+
"host all all 0.0.0.0/0 md5\n"\
97+
"host all all ::1/128 trust\n" >> /var/lib/postgresql/main/pg_hba.conf
98+
99+
RUN /usr/local/pgsql/bin/pg_ctl -w -D /var/lib/postgresql/main start && /usr/local/pgsql/bin/createdb || true # 8.0 doesn't create the postgres DB automatically
100+
101+
RUN sleep 5; /usr/local/pgsql/bin/pg_ctl -w -D /var/lib/postgresql/main start && \
102+
psql -c "CREATE USER tester WITH SUPERUSER PASSWORD 'tester'; ALTER user postgres password 'pgpass';"
103+
104+
COPY ./setup-reference-pgbench /tmp/
105+
RUN /tmp/setup-reference-pgbench $PG_VERSION
106+
107+
# Expose the PostgreSQL port
108+
EXPOSE 5432
109+
110+
# Add VOLUMEs to allow backup of config, logs and databases
111+
VOLUME ["/var/lib/postgresql"]
112+
113+
# Set the default command to run when starting the container
114+
CMD /usr/bin/pgmain

0 commit comments

Comments
 (0)