2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-10 09:02:10 +00:00

Merge branch 'develop' into staging

This commit is contained in:
Ankush Menat 2023-01-30 20:18:44 +05:30
commit b186126629
5 changed files with 27 additions and 36 deletions

View File

@ -1,16 +0,0 @@
version = 1
exclude_patterns = [
".*"
]
test_patterns = [
"bench/tests/**"
]
[[analyzers]]
name = "python"
enabled = true
dependency_file_paths = [
"requirements.txt"
]

View File

@ -87,7 +87,7 @@ Download the Easy Install script and execute it:
```sh ```sh
$ wget https://raw.githubusercontent.com/frappe/bench/develop/easy-install.py $ wget https://raw.githubusercontent.com/frappe/bench/develop/easy-install.py
$ python3 easy-install.py --prod $ python3 easy-install.py --prod --email your@email.tld
``` ```
This script will install docker on your system and will fetch the required containers, setup bench and a default ERPNext instance. This script will install docker on your system and will fetch the required containers, setup bench and a default ERPNext instance.
@ -110,10 +110,8 @@ options:
-h, --help show this help message and exit -h, --help show this help message and exit
-p, --prod Setup Production System -p, --prod Setup Production System
-d, --dev Setup Development System -d, --dev Setup Development System
-s SITENAME, --sitename SITENAME -s SITENAME, --sitename SITENAME The Site Name for your production site
The Site Name for your production site -n PROJECT, --project PROJECT Project Name
-n PROJECT, --project PROJECT
Project Name
--email EMAIL Add email for the SSL. --email EMAIL Add email for the SSL.
``` ```

View File

@ -60,6 +60,7 @@ def execute_cmd(check_for_update=True, command: str = None, logger: Logger = Non
def cli(): def cli():
setup_clear_cache()
global from_command_line, bench_config, is_envvar_warn_set, verbose global from_command_line, bench_config, is_envvar_warn_set, verbose
from_command_line = True from_command_line = True
@ -75,7 +76,6 @@ def cli():
change_working_directory() change_working_directory()
logger = setup_logging() logger = setup_logging()
logger.info(command) logger.info(command)
setup_clear_cache()
bench_config = get_config(".") bench_config = get_config(".")

View File

@ -71,14 +71,21 @@ def get_from_env(dir, file) -> Dict:
return env_vars return env_vars
def write_to_env(wd: str, site: str, db_pass: str, admin_pass: str, email: str) -> None: def write_to_env(
wd: str,
site: str,
db_pass: str,
admin_pass: str,
email: str,
erpnext_version: str = None,
) -> None:
site_name = site or "" site_name = site or ""
example_env = get_from_env(wd, "example.env") example_env = get_from_env(wd, "example.env")
erpnext_version = erpnext_version or example_env["ERPNEXT_VERSION"]
with open(os.path.join(wd, ".env"), "w") as f: with open(os.path.join(wd, ".env"), "w") as f:
f.writelines( f.writelines(
[ [
f"FRAPPE_VERSION={example_env['FRAPPE_VERSION']}\n", # Defaults to latest version of Frappe f"ERPNEXT_VERSION={erpnext_version}\n", # defaults to latest version of ERPNext
f"ERPNEXT_VERSION={example_env['ERPNEXT_VERSION']}\n", # defaults to latest version of ERPNext
f"DB_PASSWORD={db_pass}\n", f"DB_PASSWORD={db_pass}\n",
"DB_HOST=db\n", "DB_HOST=db\n",
"DB_PORT=3306\n", "DB_PORT=3306\n",
@ -107,7 +114,7 @@ def check_repo_exists() -> bool:
return os.path.exists(os.path.join(os.getcwd(), "frappe_docker")) return os.path.exists(os.path.join(os.getcwd(), "frappe_docker"))
def setup_prod(project: str, sitename: str, email: str) -> None: def setup_prod(project: str, sitename: str, email: str, version: str = None) -> None:
if check_repo_exists(): if check_repo_exists():
compose_file_name = os.path.join(os.path.expanduser("~"), f"{project}-compose.yml") compose_file_name = os.path.join(os.path.expanduser("~"), f"{project}-compose.yml")
docker_repo_path = os.path.join(os.getcwd(), "frappe_docker") docker_repo_path = os.path.join(os.getcwd(), "frappe_docker")
@ -122,7 +129,7 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
if not os.path.exists(os.path.join(docker_repo_path, ".env")): if not os.path.exists(os.path.join(docker_repo_path, ".env")):
admin_pass = generate_pass() admin_pass = generate_pass()
db_pass = generate_pass(9) db_pass = generate_pass(9)
write_to_env(docker_repo_path, sitename, db_pass, admin_pass, email) write_to_env(docker_repo_path, sitename, db_pass, admin_pass, email, version)
cprint( cprint(
"\nA .env file is generated with basic configs. Please edit it to fit to your needs \n", "\nA .env file is generated with basic configs. Please edit it to fit to your needs \n",
level=3, level=3,
@ -150,8 +157,6 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
"overrides/compose.redis.yaml", "overrides/compose.redis.yaml",
# "-f", "overrides/compose.noproxy.yaml", TODO: Add support for local proxying without HTTPs # "-f", "overrides/compose.noproxy.yaml", TODO: Add support for local proxying without HTTPs
"-f", "-f",
"overrides/compose.erpnext.yaml",
"-f",
"overrides/compose.https.yaml", "overrides/compose.https.yaml",
"--env-file", "--env-file",
".env", ".env",
@ -202,6 +207,7 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
"bench", "bench",
"new-site", "new-site",
sitename, sitename,
"--no-mariadb-socket",
"--db-root-password", "--db-root-password",
db_pass, db_pass,
"--admin-password", "--admin-password",
@ -220,7 +226,7 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
else: else:
install_docker() install_docker()
clone_frappe_docker_repo() clone_frappe_docker_repo()
setup_prod(project, sitename, email) # Recursive setup_prod(project, sitename, email, version) # Recursive
def setup_dev_instance(project: str): def setup_dev_instance(project: str):
@ -306,6 +312,9 @@ if __name__ == "__main__":
parser.add_argument( parser.add_argument(
"--email", help="Add email for the SSL.", required="--prod" in sys.argv "--email", help="Add email for the SSL.", required="--prod" in sys.argv
) )
parser.add_argument(
"-v", "--version", help="ERPNext version to install, defaults to latest stable"
)
args = parser.parse_args() args = parser.parse_args()
if args.dev: if args.dev:
cprint("\nSetting Up Development Instance\n", level=2) cprint("\nSetting Up Development Instance\n", level=2)
@ -317,6 +326,6 @@ if __name__ == "__main__":
if "example.com" in args.email: if "example.com" in args.email:
cprint("Emails with example.com not acceptable", level=1) cprint("Emails with example.com not acceptable", level=1)
sys.exit(1) sys.exit(1)
setup_prod(args.project, args.sitename, args.email) setup_prod(args.project, args.sitename, args.email, args.version)
else: else:
parser.print_help() parser.print_help()

View File

@ -20,7 +20,7 @@ classifiers = [
] ]
dependencies = [ dependencies = [
"Click>=7.0", "Click>=7.0",
"GitPython~=2.1.15", "GitPython~=3.1.30",
"honcho", "honcho",
"Jinja2~=3.0.3", "Jinja2~=3.0.3",
"python-crontab~=2.6.0", "python-crontab~=2.6.0",