diff --git a/cmdeploy/src/cmdeploy/cmdeploy.py b/cmdeploy/src/cmdeploy/cmdeploy.py index a6344e4d..56d39b1f 100644 --- a/cmdeploy/src/cmdeploy/cmdeploy.py +++ b/cmdeploy/src/cmdeploy/cmdeploy.py @@ -71,6 +71,11 @@ def run_cmd_options(parser): action="store_true", help="install/upgrade the server, but disable postfix & dovecot for now", ) + parser.add_argument( + "--website-only", + action="store_true", + help="only update/deploy the website, skipping full server upgrade/deployment, useful when you only changed/updated the web pages and don't need to re-run a full server upgrade", + ) parser.add_argument( "--skip-dns-check", dest="dns_check_disabled", @@ -93,6 +98,7 @@ def run_cmd(args, out): env = os.environ.copy() env["CHATMAIL_INI"] = args.inipath + env["CHATMAIL_WEBSITE_ONLY"] = "True" if args.website_only else "" env["CHATMAIL_DISABLE_MAIL"] = "True" if args.disable_mail else "" env["CHATMAIL_REQUIRE_IROH"] = "True" if require_iroh else "" deploy_path = importlib.resources.files(__package__).joinpath("run.py").resolve() @@ -108,7 +114,12 @@ def run_cmd(args, out): try: retcode = out.check_call(cmd, env=env) - if retcode == 0: + if args.website_only: + if retcode == 0: + out.green("Website deployment completed.") + else: + out.red("Website deployment failed.") + elif retcode == 0: out.green("Deploy completed, call `cmdeploy dns` next.") elif not remote_data["acme_account_url"]: out.red("Deploy completed but letsencrypt not configured") diff --git a/cmdeploy/src/cmdeploy/deployers.py b/cmdeploy/src/cmdeploy/deployers.py index 84b8e598..56c2c725 100644 --- a/cmdeploy/src/cmdeploy/deployers.py +++ b/cmdeploy/src/cmdeploy/deployers.py @@ -509,16 +509,21 @@ def activate(self): ) -def deploy_chatmail(config_path: Path, disable_mail: bool) -> None: +def deploy_chatmail(config_path: Path, disable_mail: bool, website_only: bool) -> None: """Deploy a chat-mail instance. :param config_path: path to chatmail.ini :param disable_mail: whether to disable postfix & dovecot + :param website_only: if True, only deploy the website """ config = read_config(config_path) check_config(config) mail_domain = config.mail_domain + if website_only: + Deployment().perform_stages([WebsiteDeployer(config)]) + return + if host.get_fact(Port, port=53) != "unbound": files.line( name="Add 9.9.9.9 to resolv.conf", diff --git a/cmdeploy/src/cmdeploy/run.py b/cmdeploy/src/cmdeploy/run.py index b9ae7421..0b0fc858 100644 --- a/cmdeploy/src/cmdeploy/run.py +++ b/cmdeploy/src/cmdeploy/run.py @@ -14,8 +14,9 @@ def main(): importlib.resources.files("cmdeploy").joinpath("../../../chatmail.ini"), ) disable_mail = bool(os.environ.get("CHATMAIL_DISABLE_MAIL")) + website_only = bool(os.environ.get("CHATMAIL_WEBSITE_ONLY")) - deploy_chatmail(config_path, disable_mail) + deploy_chatmail(config_path, disable_mail, website_only) if pyinfra.is_cli: