Skip to content

Commit

Permalink
fix: image replace and site creation
Browse files Browse the repository at this point in the history
  • Loading branch information
revant committed Sep 22, 2023
1 parent 8ba685c commit f93f065
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions easy-install.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import argparse
import fileinput
import logging
import os
import platform
Expand Down Expand Up @@ -115,6 +116,9 @@ def check_repo_exists() -> bool:


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

if check_repo_exists():
compose_file_name = os.path.join(os.path.expanduser("~"), f"{project}-compose.yml")
docker_repo_path = os.path.join(os.getcwd(), "frappe_docker")
Expand All @@ -125,11 +129,6 @@ def setup_prod(project: str, sites, email: str, version: str = None, image = Non
admin_pass = ""
db_pass = ""
with open(compose_file_name, "w") as f:
if image:
filedata = f.read()
filedata = filedata.replace("image: frappe/erpnext", f"image: {image}")
f.write(filedata)

# Writing to compose file
if not os.path.exists(os.path.join(docker_repo_path, ".env")):
admin_pass = generate_pass()
Expand Down Expand Up @@ -176,6 +175,14 @@ def setup_prod(project: str, sites, email: str, version: str = None, image = Non
logging.error("Docker Compose generation failed", exc_info=True)
cprint("\nGenerating Compose File failed\n")
sys.exit(1)

# Use custom image
if image:
for line in fileinput.input(compose_file_name, inplace=True):
if "image: frappe/erpnext" in line:
line = line.replace("image: frappe/erpnext", f"image: {image}")
sys.stdout.write(line)

try:
# Starting with generated compose file
subprocess.run(
Expand Down Expand Up @@ -321,7 +328,7 @@ def create_site(
"-s",
"--sitename",
help="Site Name(s) for your production bench",
default=["site1.localhost"],
default=[],
action="append",
dest="sites",
)
Expand Down

0 comments on commit f93f065

Please sign in to comment.