Dockerfile 2.4 KB

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