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/build/common/commands/constants.py b/build/common/commands/constants.py index b07e3381..48093f13 100644 --- a/build/common/commands/constants.py +++ b/build/common/commands/constants.py @@ -7,4 +7,6 @@ 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' +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 57c9f978..5babe6c3 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, RDS_PRIVILEGES from utils import ( run_command, get_config, @@ -93,7 +93,13 @@ def main(): run_command(command) # Grant permission to database - command = mysql_command + [f"GRANT ALL PRIVILEGES ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"] + grant_privileges = "ALL PRIVILEGES" + + # for Amazon RDS + 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: 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 "$@" 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 70% rename from .devcontainer/docker-compose.yml rename to devcontainer-example/docker-compose.yml index 104c5442..c46f21ca 100644 --- a/.devcontainer/docker-compose.yml +++ b/devcontainer-example/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/.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 diff --git a/development/README.md b/development/README.md index b4e72dce..607e53ed 100644 --- a/development/README.md +++ b/development/README.md @@ -22,9 +22,18 @@ 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). +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: