From 61a1ae62abec3c81db14fe8ae770833f13c40053 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Thu, 2 Jul 2020 15:00:27 +0200 Subject: [PATCH] Add some notes --- second.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/second.py b/second.py index f769cd5..aa35810 100644 --- a/second.py +++ b/second.py @@ -99,6 +99,14 @@ def stack_deploy(app_name, stack_name, env): """Depoy an application to the swarm.""" compose_yml = DATA_DIR / app_name / "compose.yml" command = f"docker stack deploy -c {compose_yml} {stack_name}" + + # Note(decentral1se): we're not sure if this ever succeeds actually stuff + # like https://github.com/issuu/sure-deploy could be used and once we + # graduate this to a dockerise app, we could install that all in the + # container and run it from here. Of course, if we're using JS or not might + # affect this, say, we have a page that is real-time reporting or we're + # using a static page? Unsure what the UX could be like, thinking of + # cloudron loading bar but never like those... run(split(command), env=env) @@ -107,8 +115,12 @@ def get_loaded_env(app_name, request_form): env = environ.copy() for key in request_form.keys(): + # Note(decentral1se): {"app_ini": "foo"} -> {"APP_INI": "foo"} env[key.upper()] = request.form[key] + # Note(decentral1se): maybe we don't need this in the end since we will be + # quite sure that our configs are working and we are not getting rate + # limited env["LETS_ENCRYPT_ENV"] = "staging" return env @@ -169,19 +181,23 @@ def deploy(app_name): try: mkdir(DATA_DIR) except FileExistsError: + # Note(decentral1se): we already cloned it, so keep going pass clone_app_template(app_name) + # Note(decentral1se): there are badly named and the functions have too many + # concerns but they basically load every value required into the + # environment so that it can be injected when docker stack deploy is run, + # oh and secrets are also created as part of this step ;) env = get_loaded_env(app_name, form.data) env = arrange_configs_and_secrets(app_name, form.data, env) - dump_db({form.data["stack_name"]: form.data}) - - stack_deploy(app_name, form.data["stack_name"], env) - + stack_name = form.data["stack_name"] + dump_db({stack_name: form.data}) + stack_deploy(app_name, stack_name, env) return render_template( - "second/deploy.html", app_name=app_name, stack_name=form.data["stack_name"] + "second/deploy.html", app_name=app_name, stack_name=stack_name )