blob: 7ce64219e3d53b9590035564898daa37f6cce661 [file] [log] [blame]
Zack Williams52986b22017-04-19 16:28:25 -07001# xosproject/xos-postgres
2FROM ubuntu:14.04.5
3
Zack Williamsa7fec782017-04-27 20:18:19 -07004# Version of PostgreSQL to install
5ENV PGSQL_VERSION 9.6
6
7RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
8
9RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" \
10 > /etc/apt/sources.list.d/pgdg.list
11
12RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --force-yes\
13 python-software-properties \
14 software-properties-common \
Zack Williamse0caa252017-04-30 21:20:20 -070015 postgresql-${PGSQL_VERSION} \
16 postgresql-client-${PGSQL_VERSION} \
17 postgresql-contrib-${PGSQL_VERSION} \
Zack Williamsa7fec782017-04-27 20:18:19 -070018 && rm -rf /var/lib/apt/lists/*
19
20# Workaround for AUFS issue
21# https://github.com/docker/docker/issues/783#issuecomment-56013588
22RUN mkdir /etc/ssl/private-copy; mv /etc/ssl/private/* /etc/ssl/private-copy/; rm -r /etc/ssl/private; mv /etc/ssl/private-copy /etc/ssl/private; chmod -R 0700 /etc/ssl/private; chown -R postgres /etc/ssl/private
23
24USER postgres
25
26RUN /etc/init.d/postgresql start && \
27 psql --command "ALTER USER postgres WITH SUPERUSER PASSWORD 'password' " && \
28 psql --command "CREATE DATABASE xos"
29
30# Allow remote connections.
Zack Williamse0caa252017-04-30 21:20:20 -070031RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/${PGSQL_VERSION}/main/pg_hba.conf
32RUN echo "host all all 0.0.0.0/0 password" >> /etc/postgresql/${PGSQL_VERSION}/main/pg_hba.conf
Zack Williamsa7fec782017-04-27 20:18:19 -070033
Zack Williamse0caa252017-04-30 21:20:20 -070034RUN echo "listen_addresses='*'" >> /etc/postgresql/${PGSQL_VERSION}/main/postgresql.conf
Zack Williamsa7fec782017-04-27 20:18:19 -070035
36# Expose the PostgreSQL port
37EXPOSE 5432
38
39VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
40
Zack Williams52986b22017-04-19 16:28:25 -070041# Label image
42ARG org_label_schema_schema_version=1.0
43ARG org_label_schema_name=xos-postgres
44ARG org_label_schema_version=unknown
45ARG org_label_schema_vcs_url=unknown
46ARG org_label_schema_vcs_ref=unknown
47ARG org_label_schema_build_date=unknown
48ARG org_opencord_vcs_commit_date=unknown
49
50LABEL org.label-schema.schema-version=$org_label_schema_schema_version \
51 org.label-schema.name=$org_label_schema_name \
52 org.label-schema.version=$org_label_schema_version \
53 org.label-schema.vcs-url=$org_label_schema_vcs_url \
54 org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
55 org.label-schema.build-date=$org_label_schema_build_date \
56 org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date
Tony Mack7ca8c522015-10-29 21:14:41 +000057
Zack Williamse0caa252017-04-30 21:20:20 -070058CMD /usr/lib/postgresql/${PGSQL_VERSION}/bin/postgres -D /var/lib/postgresql/${PGSQL_VERSION}/main -c config_file=/etc/postgresql/${PGSQL_VERSION}/main/postgresql.conf