From 9a228323896e3adee54eec22872a9d8e078898f0 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Wed, 15 Jul 2020 21:28:52 +0530 Subject: [PATCH 1/7] fix: mariadb grants for aws rds --- build/common/commands/constants.py | 3 ++- build/common/commands/new.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build/common/commands/constants.py b/build/common/commands/constants.py index b07e3381..d1767a38 100644 --- a/build/common/commands/constants.py +++ b/build/common/commands/constants.py @@ -7,4 +7,5 @@ DB_PORT = 3306 APP_VERSIONS_JSON_FILE = 'app_versions.json' APPS_TXT_FILE = 'apps.txt' COMMON_SITE_CONFIG_FILE = 'common_site_config.json' -DATE_FORMAT = "%Y%m%d_%H%M%S" \ No newline at end of file +DATE_FORMAT = "%Y%m%d_%H%M%S" +RDS_DB = 'rds_db' diff --git a/build/common/commands/new.py b/build/common/commands/new.py index 57c9f978..3fdf12b0 100644 --- a/build/common/commands/new.py +++ b/build/common/commands/new.py @@ -4,7 +4,7 @@ import semantic_version from frappe.commands.site import _new_site from frappe.installer import update_site_config -from constants import COMMON_SITE_CONFIG_FILE +from constants import COMMON_SITE_CONFIG_FILE, RDS_DB from utils import ( run_command, get_config, @@ -96,6 +96,11 @@ def main(): command = mysql_command + [f"GRANT ALL PRIVILEGES ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"] run_command(command) + # for Amazon RDS + if config.get(RDS_DB) or site_config.get(RDS_DB): + command = mysql_command + [f"GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, CREATE VIEW, EVENT, TRIGGER, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EXECUTE, LOCK TABLES ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"] + run_command(command) + if frappe.redis_server: frappe.redis_server.connection_pool.disconnect() From c2ebdfcf8b602c7f12795cbfa82884a4afec7810 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 16 Jul 2020 06:06:48 +0530 Subject: [PATCH 2/7] fix: condition for mariadb grants for aws rds --- build/common/commands/constants.py | 1 + build/common/commands/new.py | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build/common/commands/constants.py b/build/common/commands/constants.py index d1767a38..48093f13 100644 --- a/build/common/commands/constants.py +++ b/build/common/commands/constants.py @@ -9,3 +9,4 @@ APPS_TXT_FILE = 'apps.txt' COMMON_SITE_CONFIG_FILE = 'common_site_config.json' DATE_FORMAT = "%Y%m%d_%H%M%S" RDS_DB = 'rds_db' +RDS_PRIVILEGES = "SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, CREATE VIEW, EVENT, TRIGGER, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EXECUTE, LOCK TABLES" diff --git a/build/common/commands/new.py b/build/common/commands/new.py index 3fdf12b0..c9a39cf2 100644 --- a/build/common/commands/new.py +++ b/build/common/commands/new.py @@ -4,7 +4,7 @@ import semantic_version from frappe.commands.site import _new_site from frappe.installer import update_site_config -from constants import COMMON_SITE_CONFIG_FILE, RDS_DB +from constants import COMMON_SITE_CONFIG_FILE, RDS_DB, RDS_PRIVILEGES from utils import ( run_command, get_config, @@ -93,13 +93,14 @@ def main(): run_command(command) # Grant permission to database - command = mysql_command + [f"GRANT ALL PRIVILEGES ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"] - run_command(command) + grant_privileges = "ALL PRIVILEGES" # for Amazon RDS - if config.get(RDS_DB) or site_config.get(RDS_DB): - command = mysql_command + [f"GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, CREATE VIEW, EVENT, TRIGGER, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EXECUTE, LOCK TABLES ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"] - run_command(command) + if config.get(RDS_DB) or site_config.get(RDS_DB) + grant_privileges = RDS_PRIVILEGES + + command = mysql_command + [f"GRANT {grant_privileges} ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"] + run_command(command) if frappe.redis_server: frappe.redis_server.connection_pool.disconnect() From c2a0e4f05761d8dd7b01c362b677ccd8d8c738df Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 16 Jul 2020 06:08:24 +0530 Subject: [PATCH 3/7] fix: condition for grants for aws rds --- build/common/commands/new.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/common/commands/new.py b/build/common/commands/new.py index c9a39cf2..5babe6c3 100644 --- a/build/common/commands/new.py +++ b/build/common/commands/new.py @@ -96,7 +96,7 @@ def main(): grant_privileges = "ALL PRIVILEGES" # for Amazon RDS - if config.get(RDS_DB) or site_config.get(RDS_DB) + if config.get(RDS_DB) or site_config.get(RDS_DB): grant_privileges = RDS_PRIVILEGES command = mysql_command + [f"GRANT {grant_privileges} ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"] From 8fe7d324d9bb3a65884ba5bdef80c84bef0749a9 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Fri, 17 Jul 2020 07:05:39 +0530 Subject: [PATCH 4/7] fix: workaround for vscode debugger issue [skip travis] fixes #313 --- development/.vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/.vscode/settings.json b/development/.vscode/settings.json index 17a5d56d..78469229 100644 --- a/development/.vscode/settings.json +++ b/development/.vscode/settings.json @@ -1,4 +1,4 @@ { "python.pythonPath": "frappe-bench/env/bin/python", - "debug.node.autoAttach": "on" + "debug.node.autoAttach": "disabled" } \ No newline at end of file From 55e4a53d5bb3f299982fc25f9a7f85e883161611 Mon Sep 17 00:00:00 2001 From: Hendy Irawan Date: Sat, 1 Aug 2020 12:26:03 +0700 Subject: [PATCH 5/7] refactor: Disable PostgreSQL by default, fixes #317 --- .devcontainer/docker-compose.yml | 15 ++++++++------- development/README.md | 5 ++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 104c5442..c46f21ca 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -9,13 +9,14 @@ services: - ../installation/frappe-mariadb.cnf:/etc/mysql/conf.d/frappe.cnf - mariadb-vol:/var/lib/mysql - postgresql: - image: postgres:11.8 - restart: on-failure - environment: - - POSTGRES_PASSWORD=123 - volumes: - - postgresql-vol:/var/lib/postgresql/data + # Enable PostgreSQL only if you use it, see development/README.md for more information. + # postgresql: + # image: postgres:11.8 + # restart: on-failure + # environment: + # - POSTGRES_PASSWORD=123 + # volumes: + # - postgresql-vol:/var/lib/postgresql/data redis-cache: image: redis:alpine diff --git a/development/README.md b/development/README.md index b4e72dce..f7e4bc25 100644 --- a/development/README.md +++ b/development/README.md @@ -24,7 +24,10 @@ cd frappe_docker ## Use VSCode Remote Containers extension -For most people getting started with Frappe development, the best solution is to use [ VSCode Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). +For most people getting started with Frappe development, the best solution is to use [VSCode Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). + +Before opening the folder in container, determine the database that you want to use. The default is MariaDB. +If you want to use PostgreSQL instead, edit `.devcontainer/docker-compose.yml` and uncomment the section for `postgresql` service, and you may also want to comment `mariadb` as well. VSCode should automatically inquire you to install the required extensions, that can also be installed manually as follows: From 247a8e8e2da2c43f311a0c2534f16bbfa6ba2a72 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sat, 1 Aug 2020 23:24:09 +0530 Subject: [PATCH 6/7] fix: gitignore .devcontainer --- .gitignore | 3 +++ {.devcontainer => devcontainer-example}/devcontainer.json | 0 {.devcontainer => devcontainer-example}/docker-compose.yml | 0 development/README.md | 6 ++++++ 4 files changed, 9 insertions(+) rename {.devcontainer => devcontainer-example}/devcontainer.json (100%) rename {.devcontainer => devcontainer-example}/docker-compose.yml (100%) diff --git a/.gitignore b/.gitignore index c5aa2d25..e6ae4965 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ deploy_key.pub # Pycharm .idea + +# VS Code devcontainer +.devcontainer diff --git a/.devcontainer/devcontainer.json b/devcontainer-example/devcontainer.json similarity index 100% rename from .devcontainer/devcontainer.json rename to devcontainer-example/devcontainer.json diff --git a/.devcontainer/docker-compose.yml b/devcontainer-example/docker-compose.yml similarity index 100% rename from .devcontainer/docker-compose.yml rename to devcontainer-example/docker-compose.yml diff --git a/development/README.md b/development/README.md index f7e4bc25..607e53ed 100644 --- a/development/README.md +++ b/development/README.md @@ -22,6 +22,12 @@ git clone https://github.com/frappe/frappe_docker.git cd frappe_docker ``` +Copy example devcontainer config from `devcontainer-example` to `.devcontainer` + +```shell +cp -R devcontainer-example .devcontainer +``` + ## Use VSCode Remote Containers extension For most people getting started with Frappe development, the best solution is to use [VSCode Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). From dbd56ee99b863853cf0c7786726ea182d19132ca Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sun, 2 Aug 2020 19:22:16 +0530 Subject: [PATCH 7/7] fix(erpnext-nginx): remove unused docker-entrypoint script fixes #321 --- build/erpnext-nginx/docker-entrypoint.sh | 47 ------------------------ 1 file changed, 47 deletions(-) delete mode 100755 build/erpnext-nginx/docker-entrypoint.sh diff --git a/build/erpnext-nginx/docker-entrypoint.sh b/build/erpnext-nginx/docker-entrypoint.sh deleted file mode 100755 index c1caad54..00000000 --- a/build/erpnext-nginx/docker-entrypoint.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -## Thanks -# https://serverfault.com/a/919212 -## - -set -e - -rsync -a --delete /var/www/html/assets/js /assets -rsync -a --delete /var/www/html/assets/css /assets -rsync -a --delete /var/www/html/assets/frappe /assets -. /rsync - -chmod -R 755 /assets - -if [[ -z "$FRAPPE_PY" ]]; then - export FRAPPE_PY=0.0.0.0 -fi - -if [[ -z "$FRAPPE_PY_PORT" ]]; then - export FRAPPE_PY_PORT=8000 -fi - -if [[ -z "$FRAPPE_SOCKETIO" ]]; then - export FRAPPE_SOCKETIO=0.0.0.0 -fi - -if [[ -z "$SOCKETIO_PORT" ]]; then - export SOCKETIO_PORT=9000 -fi - -envsubst '${API_HOST} - ${API_PORT} - ${FRAPPE_PY} - ${FRAPPE_PY_PORT} - ${FRAPPE_SOCKETIO} - ${SOCKETIO_PORT}' \ - < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf - -echo "Waiting for frappe-python to be available on $FRAPPE_PY port $FRAPPE_PY_PORT" -timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_PY $FRAPPE_PY_PORT -echo "Frappe-python available on $FRAPPE_PY port $FRAPPE_PY_PORT" -echo "Waiting for frappe-socketio to be available on $FRAPPE_SOCKETIO port $SOCKETIO_PORT" -timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_SOCKETIO $SOCKETIO_PORT -echo "Frappe-socketio available on $FRAPPE_SOCKETIO port $SOCKETIO_PORT" - -exec "$@"