Files

35 lines
1.4 KiB
Docker
Raw Permalink Normal View History

2017-11-07 09:23:57 +01:00
from ubuntu:16.04
RUN apt-get update && apt-get install -y sudo vim
RUN apt-get install -y \
apt-utils \
postgresql \
postgresql-client \
postgresql-client-common \
postgresql-contrib \
libpq-dev
RUN sudo cat /etc/postgresql/9.5/main/pg_hba.conf
RUN sudo echo "local all postgres trust" > /etc/postgresql/9.5/main/pg_hba.conf && \
sudo echo "local all all trust" >> /etc/postgresql/9.5/main/pg_hba.conf && \
sudo echo "host all all 127.0.0.1/32 trust" >> /etc/postgresql/9.5/main/pg_hba.conf && \
sudo echo "host all all ::1/128 trust" >> /etc/postgresql/9.5/main/pg_hba.conf
USER postgres
RUN /etc/init.d/postgresql start && \
createdb test && \
createdb pivotal && \
echo "CREATE ROLE pivotal WITH UNENCRYPTED PASSWORD 'password';" | psql -U postgres && \
echo "ALTER ROLE pivotal WITH LOGIN;" | psql -U postgres && \
echo "GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA public TO pivotal;" | psql -U postgres && \
echo "GRANT CREATE, CONNECT ON DATABASE test TO pivotal;" | psql -U postgres && \
echo "GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA public TO pivotal;" | psql -U postgres && \
echo "GRANT CREATE, CONNECT ON DATABASE pivotal TO pivotal;" | psql -U postgres
EXPOSE 5432
CMD ["/usr/lib/postgresql/9.5/bin/postgres", "-D", "/var/lib/postgresql/9.5/main", "-c", "config_file=/etc/postgresql/9.5/main/postgresql.conf"]