-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathubuntu22-postgres.dockerfile
44 lines (36 loc) · 1.6 KB
/
ubuntu22-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
42
43
44
FROM "ubuntu:22.04"
LABEL __copyright__="(C) Guido U. Draheim, licensed under the EUPL" \
__version__="1.5.8065"
ENV PG /var/lib/postgresql/14/main
ENV CNF_FILE /etc/postgresql/14/main/postgresql.conf
ENV HBA_FILE /etc/postgresql/14/main/pg_hba.conf
ENV LOG_FILE /var/log/postgresql/postgresql-14-main.log
ENV POSTGRES postgresql@14-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 -e /bin/systemctl || ln -sf /usr/bin/systemctl /bin/systemctl
# fix ubuntu:22.04 problem
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
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