-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-CentOS7-PG12
55 lines (42 loc) · 2.16 KB
/
Dockerfile-CentOS7-PG12
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
#########################################################################
# #
# Dockerfile for Fedora PostgreSQL Spin, with PGDG RPM packages. #
# Devrim Gündüz <[email protected]> #
# #
#########################################################################
FROM centos:latest
MAINTAINER [email protected]
# Add the PostgreSQL PGP key to verify the official yum repository packages
RUN rpm --import https://yum.postgresql.org/RPM-GPG-KEY-PGDG-12
# Add PostgreSQL's repository. It contains the most recent stable release
# of PostgreSQL, 12:
RUN yum -q -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Update the Fedora and PostgreSQL repository metadata
RUN yum -q -y install deltarpm
RUN yum -q -y update
# Install PostgreSQL 12 and some useful packages:
RUN yum -q -y install postgresql12-server postgresql12-contrib procps-ng net-tools
# Run the rest of the commands as the postgres user created by the postgresql12-server
# package when it was yum installed
USER postgres
# initdb PostgreSQL 12:
RUN /usr/pgsql-12/bin/initdb -D /var/lib/pgsql/12/data -A trust 2>&1 < /dev/null
# Adjust PostgreSQL configuration so that remote connections to the
# database are possible.
RUN echo "host all all 0.0.0.0/0 md5" >> /var/lib/pgsql/12/data/pg_hba.conf
# And add listen_addresses to /var/lib/pgsql/12/data/postgresql.conf
RUN echo "listen_addresses='*'" >> /var/lib/pgsql/12/data/postgresql.conf
# Create a PostgreSQL role named 'docker' with 'docker' as the password and
# then create a database 'docker' owned by the 'docker' role.
# After start, sleep for 5 secs to make sure that postmaster is started before
# creating the role and database:
RUN /usr/pgsql-12/bin/pg_ctl -D /var/lib/pgsql/12/data start &&\
sleep 5 &&\
psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\
createdb -O docker docker
# Expose the PostgreSQL port
EXPOSE 5432
# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/var/lib/pgsql/12"]
# Set the default command to run when starting the container
CMD ["/usr/pgsql-12/bin/postgres", "-D", "/var/lib/pgsql/12/data"]