-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1034 from onaio/update-postgres-in-docker-install…
…ation-docs Update Postgres install docs to use docker-compose.
- Loading branch information
Showing
1 changed file
with
9 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
------------ | ||
|