Skip to content

Commit

Permalink
fix(easy-install): install app configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
revant committed Oct 29, 2024
1 parent 502c9a2 commit c07dfc5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/easy-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Perform production easy install
run: |
python3 ${GITHUB_WORKSPACE}/easy-install.py build
python3 ${GITHUB_WORKSPACE}/easy-install.py -p -n actions_test --email [email protected] --image custom-apps --version latest
python3 ${GITHUB_WORKSPACE}/easy-install.py -p -n actions_test --email [email protected] --image custom-apps --version latest --app erpnext
docker compose -p actions_test exec backend bench version --format json
docker compose -p actions_test exec backend bench --site site1.localhost list-apps --format json
result=$(curl -H "Host: site1.localhost" -sk https://127.0.0.1/api/method/ping | jq -r ."message")
Expand Down
59 changes: 35 additions & 24 deletions easy-install.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def check_repo_exists() -> bool:
return os.path.exists(os.path.join(os.getcwd(), "frappe_docker"))


def setup_prod(project: str, sites, email: str, version: str = None, image = None) -> None:
def setup_prod(project: str, sites, email: str, version: str = None, image = None, apps = []) -> None:
if len(sites) == 0:
sites = ["site1.localhost"]

Expand Down Expand Up @@ -208,12 +208,12 @@ def setup_prod(project: str, sites, email: str, version: str = None, image = Non
sys.exit(1)

for sitename in sites:
create_site(sitename, project, db_pass, admin_pass)
create_site(sitename, project, db_pass, admin_pass, apps)

else:
install_docker()
clone_frappe_docker_repo()
setup_prod(project, sites, email, version, image) # Recursive
setup_prod(project, sites, email, version, image, apps) # Recursive


def setup_dev_instance(project: str):
Expand Down Expand Up @@ -286,30 +286,34 @@ def create_site(
project: str,
db_pass: str,
admin_pass: str,
apps: List[str] = [],
):
cprint(f"\nCreating site: {sitename} \n", level=3)
command = [
which("docker"),
"compose",
"-p",
project,
"exec",
"backend",
"bench",
"new-site",
sitename,
"--no-mariadb-socket",
"--db-root-password",
db_pass,
"--admin-password",
admin_pass,
"--set-default",
]

for app in apps:
command.append("--install-app")
command.append(app)

try:
subprocess.run(
[
which("docker"),
"compose",
"-p",
project,
"exec",
"backend",
"bench",
"new-site",
sitename,
"--no-mariadb-socket",
"--db-root-password",
db_pass,
"--admin-password",
admin_pass,
"--install-app",
"erpnext",
"--set-default",
],
command,
check=True,
)
logging.info("New site creation completed")
Expand All @@ -330,7 +334,7 @@ def add_build_parser(argparser: argparse.ArgumentParser):
build.add_argument(
"-r",
"--frappe-path",
help="Frappe Repository to use, default: https://github.com/frappe/frappe", # noqa: E501
help="Frappe Repository to use, default: https://github.com/frappe/frappe",
default="https://github.com/frappe/frappe",
)
build.add_argument(
Expand Down Expand Up @@ -468,6 +472,13 @@ def build_image(
parser.add_argument(
"-v", "--version", help="ERPNext version to install, defaults to latest stable"
)
parser.add_argument(
"-a",
"--app",
dest="apps",
help="list of app(s) to be installed",
action="append",
)
args = parser.parse_args()

if args.subcommand == 'build':
Expand All @@ -493,6 +504,6 @@ def build_image(
if "example.com" in args.email:
cprint("Emails with example.com not acceptable", level=1)
sys.exit(1)
setup_prod(args.project, args.sites, args.email, args.version, args.image)
setup_prod(args.project, args.sites, args.email, args.version, args.image, args.apps)
else:
parser.print_help()

0 comments on commit c07dfc5

Please sign in to comment.