-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathubuntu18-postgres.dockerfile
41 lines (34 loc) · 1.5 KB
/
ubuntu18-postgres.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
FROM "ubuntu:18.04"
LABEL __copyright__="(C) Guido U. Draheim, licensed under the EUPL" \
__version__="1.5.8065"
ENV PG /var/lib/postgresql/10/main
ENV CNF_FILE /etc/postgresql/10/main/postgresql.conf
ENV HBA_FILE /etc/postgresql/10/main/pg_hba.conf
ENV LOG_FILE /var/log/postgresql/postgresql-10-main.log
ENV POSTGRES postgresql@10-main
ARG USERNAME=testuser_OK
ARG TESTUSER=testuser_11
ARG LISTEN=*
ARG ALLOWS=0.0.0.0/0
EXPOSE 5432
RUN apt-get update
RUN apt-get install -y python3
COPY files/docker/systemctl3.py /usr/bin/systemctl
RUN test -L /bin/systemctl || ln -sf /usr/bin/systemctl /bin/systemctl
RUN apt-cache search postgres
RUN apt-get install -y postgresql postgresql-contrib
COPY files/docker/systemctl3.py /usr/bin/systemctl
RUN pg_conftool show all
RUN sed -i -e "s/.*listen_addresses.*/listen_addresses = '${LISTEN}'/" $CNF_FILE
RUN sed -i -e "s/.*host.*ident/# &/" $HBA_FILE
RUN echo "host all all ${ALLOWS} md5" >> $HBA_FILE
# RUN systemctl start $POSTGRES -vvvv ; cat $LOG_FILE
RUN systemctl start $POSTGRES \
; echo "CREATE USER ${TESTUSER} LOGIN ENCRYPTED PASSWORD '${TESTPASS}'" | runuser -u postgres /usr/bin/psql \
; echo "CREATE USER ${USERNAME} LOGIN ENCRYPTED PASSWORD '${PASSWORD}'" | runuser -u postgres /usr/bin/psql \
; systemctl stop $POSTGRES
RUN systemctl enable $POSTGRES
RUN rm -f /etc/init.d/postgresql /etc/init.d/sysstat /etc/init.d/cron
CMD /usr/bin/systemctl -1