Dockerfile 2.4 KB

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