Skip to content

Commit

Permalink
Merge pull request #1034 from onaio/update-postgres-in-docker-install…
Browse files Browse the repository at this point in the history
…ation-docs

Update Postgres install docs to use docker-compose.
  • Loading branch information
ukanga authored Jun 7, 2017
2 parents 3d91c11 + 602d6af commit bf5cf1b
Showing 1 changed file with 9 additions and 27 deletions.
36 changes: 9 additions & 27 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,26 @@ Replace username and db name accordingly.
In Docker
~~~~~~~~~
To run Postgres 9.6.3 with postgis 2.3.0 in Docker:

These are just examples and you shouldn't run them as they are in production:
To run this use the Dockerfile in
`onaio/docker-builds <https://github.com/onaio/docker-builds/tree/master/postgres>`_
for postgres 9.6.0 with postgis 2.3.0 and run:
We shall use the Ona Docker builds `onaio/docker-builds <https://github.com/onaio/docker-builds>`

.. code-block:: sh
mkdir ~/docker-images/postgres-9.6/
cd ~/docker-images/postgres-9.6
docker build -t postgres:9.6.1 .
git clone [email protected]:onaio/docker-builds.git
cd docker-builds/postgresql
mkdir ~/.postgresql/onadata/data
POSTGRES_PASSWORD=<password> docker-compose up -d
.. note::

This will be a persisted using ~/.postgresql/data

.. code-block:: sh
mkdir ~/.postgresql/data
docker run -e POSTGRES_PASSWORD=pass -p 5432:5432 --volume ~/.postgresql/data:/var/lib/postgresql/data --name onadata -d postgres:9.6.1
Connect using psql with:
Connect to postgres using psql with:

.. code-block:: sh
psql -h localhost -p 5432 -U postgres
In psql:

.. code-block:: sql
CREATE USER <username> WITH PASSWORD '<password>' SUPERUSER CREATEDB LOGIN;
CREATE DATABASE <database-name> WITH ENCODING='UTF8' LC_CTYPE='en_US.UTF-8' LC_COLLATE='en_US.UTF-8' OWNER=<username> TEMPLATE=template0;
CONNECT <database-name>;
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS postgis_topology;
From now onwards start the onadata database with ``docker start onadata-postgres``

From now onwards start your DB with ``docker start onadata`` provided you passed
the name "onadata" to Docker's ``--name`` option.
You can then initialize the users and database as explained above.

Get the code
------------
Expand Down

0 comments on commit bf5cf1b

Please sign in to comment.