From 04f98778bbe4f0de35ad7873fa990d8ce6df0ef5 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Tue, 30 Jun 2020 15:27:14 +0530 Subject: [PATCH] docs: frappe docker support for PostgreSQL --- development/README.md | 17 ++++++++++ docs/site-operations.md | 34 +++++++++++++++++-- .../frappe-postgresql/docker-compose.yml | 1 + 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/development/README.md b/development/README.md index 030bfe35..b4e72dce 100644 --- a/development/README.md +++ b/development/README.md @@ -104,6 +104,23 @@ This will create a new site and a `mysite.localhost` directory under `frappe-ben The option `--no-mariadb-socket` will configure site's database credentials to work with docker. You may need to configure your system /etc/hosts if you're on Linux, Mac, or its Windows equivalent. +To setup site with PostgreSQL as database use option `--db-type postgres` and `--db-host postgresql`. (Available only v12 onwards, currently NOT available for ERPNext). + +Example: + +```shell +bench new-site mypgsql.localhost --db-type postgres --db-host postgresql +``` + +To avoid entering postgresql username and root password, set it in `common_site_config.json`, + +```shell +bench config set-common-config -c root_login postgres +bench config set-common-config -c root_password '"123"' +``` + +Note: If PostgreSQL is not required, the postgresql service / container can be stopped. + ### Set bench developer mode on the new site To develop a new app, the last step will be setting the site into developer mode. Documentation is available at [this link](https://frappe.io/docs/user/en/guides/app-development/how-enable-developer-mode-in-frappe). diff --git a/docs/site-operations.md b/docs/site-operations.md index 5fa29483..f6dab293 100644 --- a/docs/site-operations.md +++ b/docs/site-operations.md @@ -12,10 +12,12 @@ Or specify environment variables instead of passing secrets as command arguments Note: -- Wait for the MariaDB service to start before trying to create a new site. +- Wait for the database service to start before trying to create a new site. - If new site creation fails, retry after the MariaDB container is up and running. - If you're using a managed database instance, make sure that the database is running before setting up a new site. +#### MariaDB Site + ```sh # Create ERPNext site docker run \ @@ -29,10 +31,28 @@ docker run \ frappe/erpnext-worker:$VERSION new ``` +#### PostgreSQL Site + +PostgreSQL is only available v12 onwards. It is NOT available for ERPNext. +It is available as part of `frappe/erpnext-worker`. It inherits from `frappe/frappe-worker`. + +```sh +# Create ERPNext site +docker run \ + -e "SITE_NAME=$SITE_NAME" \ + -e "DB_ROOT_USER=$DB_ROOT_USER" \ + -e "POSTGRES_HOST=$POSTGRES_HOST" \ + -e "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" \ + -e "ADMIN_PASSWORD=$ADMIN_PASSWORD" \ + -v _sites-vol:/home/frappe/frappe-bench/sites \ + --network _default \ + frappe/erpnext-worker:$VERSION new +``` + Environment Variables needed: - `SITE_NAME`: name of the new site to create. Site name is domain name that resolves. e.g. `erp.example.com` or `erp.localhost`. -- `DB_ROOT_USER`: MariaDB Root user. +- `DB_ROOT_USER`: MariaDB/PostgreSQL Root user. - `MYSQL_ROOT_PASSWORD`: In case of the MariaDB docker container use the one set in `MYSQL_ROOT_PASSWORD` in previous steps. In case of a managed database use the appropriate password. - `MYSQL_ROOT_PASSWORD_FILE` - When the MariaDB root password is stored using docker secrets. - `ADMIN_PASSWORD`: set the administrator password for the new site. @@ -40,6 +60,16 @@ Environment Variables needed: - `INSTALL_APPS=erpnext`: available only in erpnext-worker and erpnext containers (or other containers with custom apps). Installs ERPNext (and/or the specified apps, comma-delinieated) on this new site. - `FORCE=1`: optional variable which force installation of the same site. +Environment Variables for PostgreSQL only: + +- `POSTGRES_HOST`: host for PostgreSQL server +- `POSTGRES_PASSWORD`: Password for `postgres`. The database root user. + +Notes: + +- To setup existing frappe-bench deployment with default database as PostgreSQL edit the common_site_config.json and set `db_host` to PostgreSQL hostname and `db_port` to PostgreSQL port. +- To create new frappe-bench deployment with default database as PostgreSQL use `POSTGRES_HOST` and `DB_PORT` environment variables in `erpnext-python` service instead of `MARIADB_HOST` + ## Add sites to proxy Change `SITES` variable to the list of sites created encapsulated in backtick and separated by comma with no space. e.g. ``SITES=`site1.example.com`,`site2.example.com` ``. diff --git a/installation/frappe-postgresql/docker-compose.yml b/installation/frappe-postgresql/docker-compose.yml index a94c21f0..8f479aa2 100644 --- a/installation/frappe-postgresql/docker-compose.yml +++ b/installation/frappe-postgresql/docker-compose.yml @@ -52,6 +52,7 @@ services: restart: on-failure environment: - POSTGRES_HOST=${POSTGRES_HOST} + - DB_PORT=5432 - REDIS_CACHE=redis-cache:6379 - REDIS_QUEUE=redis-queue:6379 - REDIS_SOCKETIO=redis-socketio:6379