-
Notifications
You must be signed in to change notification settings - Fork 16
/
Dockerfile
75 lines (54 loc) · 2.99 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
FROM ubuntu:xenial
MAINTAINER [email protected]
### CHANGE THE FOLLOWING 3 PARAMETERS IF YOU WANNA CHANGE USER, POSTGRES INSTALL AND PGDATA DIRECTORIES ###
ENV PGUSER=postgres
ENV PGBINDIR=/home/$PGUSER/pgsql
ENV PGDATADIR=/home/$PGUSER/pgdata
#Installing packages and creating a OS user
RUN apt-get update && \
apt-get install -y \
sudo wget apt-transport-https joe less build-essential \
libreadline-dev zlib1g-dev flex bison libxml2-dev \
libxslt-dev libssl-dev screen git unzip cpanminus && \
useradd -c /home/$PGUSER -ms /bin/bash $PGUSER
#add user postgres to sudoers - SECURITY WARNING
run echo "$PGUSER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
run cpanm TAP::Parser::SourceHandler::pgTAP
# The next steps will run as postgres
USER $PGUSER
WORKDIR /home/$PGUSER
#getting the -latest- (ALWAYS) postgres version compile world and install
RUN wget https://www.postgresql.org/ftp/latest/ -q -O - |grep "tar.gz" |grep -v md5 |grep -v sha256 |awk -F "\"" '{print $2}' |xargs wget && \
ls -1 *.tar.gz |xargs tar zxfv && \
cd postgres* ; ./configure --prefix=$PGBINDIR ; make world ; make install-world
### Downloading pg_jobmon
RUN git clone https://github.com/omniti-labs/pg_jobmon/
RUN export PATH=$PATH:$PGBINDIR/bin && cd /home/$PGUSER/pg_jobmon/ && make && make install
RUN wget -c http://api.pgxn.org/dist/pgtap/1.1.0/pgtap-1.1.0.zip
RUN unzip pgtap-*
RUN export PATH=$PATH:$PGBINDIR/bin && cd pgtap-1.1.0 && make && make install
# PGDATA creation and initdb -WITH- data checksums
RUN mkdir $PGDATADIR && \
$PGBINDIR/bin/initdb -k -D $PGDATADIR
# setting some postgres configurables
RUN echo "listen_addresses = '*'" >> $PGDATADIR/postgresql.conf && \
echo "port = 5432" >> $PGDATADIR/postgresql.conf
## Setting pg_hba.conf for passwordless access for all users and replication -- SECURITY WARNING
#install some extensions , create a replication user and a monkey database
RUN $PGBINDIR/bin/pg_ctl -D $PGDATADIR/ start ; sleep 10 && \
$PGBINDIR/bin/psql -c "create extension dblink;" template1 && \
$PGBINDIR/bin/psql -c "create extension pgtap;" template1 && \
$PGBINDIR/bin/psql -c "create extension postgres_fdw;" template1 && \
$PGBINDIR/bin/createdb monkey && \
$PGBINDIR/bin/psql -c "CREATE SCHEMA jobmon;" monkey && \
$PGBINDIR/bin/psql -c "CREATE extension pg_jobmon schema jobmon;" monkey && \
$PGBINDIR/bin/psql -c "insert into jobmon.dblink_mapping_jobmon (username,port) values ('postgres','5432');" monkey && \
$PGBINDIR/bin/pg_ctl -D $PGDATADIR/ -m fast stop
RUN echo "#!/bin/bash" > /home/$PGUSER/test_jobmon.sh && \
echo "/home/$PGUSER/pgsql/bin/pg_ctl -D $PGDATADIR start" >>/home/$PGUSER/test_jobmon.sh && \
echo "sleep 3" >>/home/$PGUSER/test_jobmon.sh && \
echo "/usr/local/bin/pg_prove -b /home/$PGUSER/pgsql/bin/psql -f -v /home/postgres/pg_jobmon/test/test0* -d monkey" >>/home/$PGUSER/test_jobmon.sh && \
chmod +x /home/$PGUSER/test_jobmon.sh
#USER root
CMD sudo service ssh restart && $PGBINDIR/bin/pg_ctl -D $PGDATADIR start && sleep 1 && tail -f /home/$PGUSER/pgdata/log/*.log
#Tadah !