-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostgresql
49 lines (38 loc) · 1.31 KB
/
postgresql
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
# Postgresql version
ENV PG_VERSION 9.6
ENV PGVERSION 96
# Set the environment variables
ENV HOME /var/lib/pgsql
ENV PGDATA /var/lib/pgsql/9.6/data
# Install postgresql and run InitDB
RUN rpm -vih https://download.postgresql.org/pub/repos/yum/$PG_VERSION/redhat/rhel-7-x86_64/pgdg-centos$PGVERSION-$PG_VERSION-2.noarch.rpm && \
yum update -y && \
yum install -y sudo \
pwgen \
postgresql$PGVERSION \
postgresql$PGVERSION-server \
postgresql$PGVERSION-contrib && \
yum clean all
# Copy
COPY data/postgresql-setup /usr/pgsql-$PG_VERSION/bin/postgresql$PGVERSION-setup
# Working directory
WORKDIR /var/lib/pgsql
# Run initdb
RUN /usr/pgsql-$PG_VERSION/bin/postgresql$PGVERSION-setup initdb
# Copy config file
COPY data/postgresql.conf /var/lib/pgsql/$PG_VERSION/data/postgresql.conf
COPY data/pg_hba.conf /var/lib/pgsql/$PG_VERSION/data/pg_hba.conf
COPY data/postgresql.sh /usr/local/bin/postgresql.sh
# Change own user
RUN chown -R postgres:postgres /var/lib/pgsql/$PG_VERSION/data/* && \
usermod -G wheel postgres && \
sed -i 's/.*requiretty$/#Defaults requiretty/' /etc/sudoers && \
chmod +x /usr/local/bin/postgresql.sh
# Set volume
VOLUME ["/var/lib/pgsql"]
# Set username
USER postgres
# Run PostgreSQL Server
CMD ["/bin/bash", "/usr/local/bin/postgresql.sh"]
# Expose ports.
EXPOSE 5432