Dockerfile 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. FROM ubuntu
  2. MAINTAINER [email protected]
  3. # Add the PostgreSQL PGP key to verify their Debian packages.
  4. # It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
  5. RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
  6. # Add PostgreSQL's repository. It contains the most recent stable release
  7. # of PostgreSQL, ``9.3``.
  8. RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
  9. # Update the Ubuntu and PostgreSQL repository indexes
  10. RUN apt-get update
  11. # Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
  12. # There are some warnings (in red) that show up during the build. You can hide
  13. # them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
  14. RUN apt-get -y -q install python-software-properties software-properties-common
  15. RUN apt-get -y -q install postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
  16. # Note: The official Debian and Ubuntu images automatically ``apt-get clean``
  17. # after each ``apt-get``
  18. # Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
  19. USER postgres
  20. # Create a PostgreSQL role named ``docker`` with ``docker`` as the password and
  21. # then create a database `docker` owned by the ``docker`` role.
  22. # Note: here we use ``&&\`` to run commands one after the other - the ``\``
  23. # allows the RUN command to span multiple lines.
  24. RUN /etc/init.d/postgresql start &&\
  25. psql --command "CREATE USER root WITH SUPERUSER PASSWORD 'THE_DB_PASSWORD';" &&\
  26. createdb -O root gogs
  27. # Adjust PostgreSQL configuration so that remote connections to the
  28. # database are possible.
  29. RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
  30. # And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf``
  31. RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
  32. # Expose the PostgreSQL port
  33. EXPOSE 5432
  34. # Add VOLUMEs to allow backup of config, logs and databases
  35. VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
  36. # Set the default command to run when starting the container
  37. CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]