Add some notes
This commit is contained in:
parent
eadb17d8c1
commit
61a1ae62ab
26
second.py
26
second.py
@ -99,6 +99,14 @@ def stack_deploy(app_name, stack_name, env):
|
|||||||
"""Depoy an application to the swarm."""
|
"""Depoy an application to the swarm."""
|
||||||
compose_yml = DATA_DIR / app_name / "compose.yml"
|
compose_yml = DATA_DIR / app_name / "compose.yml"
|
||||||
command = f"docker stack deploy -c {compose_yml} {stack_name}"
|
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)
|
run(split(command), env=env)
|
||||||
|
|
||||||
|
|
||||||
@ -107,8 +115,12 @@ def get_loaded_env(app_name, request_form):
|
|||||||
env = environ.copy()
|
env = environ.copy()
|
||||||
|
|
||||||
for key in request_form.keys():
|
for key in request_form.keys():
|
||||||
|
# Note(decentral1se): {"app_ini": "foo"} -> {"APP_INI": "foo"}
|
||||||
env[key.upper()] = request.form[key]
|
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"
|
env["LETS_ENCRYPT_ENV"] = "staging"
|
||||||
|
|
||||||
return env
|
return env
|
||||||
@ -169,19 +181,23 @@ def deploy(app_name):
|
|||||||
try:
|
try:
|
||||||
mkdir(DATA_DIR)
|
mkdir(DATA_DIR)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
|
# Note(decentral1se): we already cloned it, so keep going
|
||||||
pass
|
pass
|
||||||
|
|
||||||
clone_app_template(app_name)
|
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 = get_loaded_env(app_name, form.data)
|
||||||
env = arrange_configs_and_secrets(app_name, form.data, env)
|
env = arrange_configs_and_secrets(app_name, form.data, env)
|
||||||
|
|
||||||
dump_db({form.data["stack_name"]: form.data})
|
stack_name = form.data["stack_name"]
|
||||||
|
dump_db({stack_name: form.data})
|
||||||
stack_deploy(app_name, form.data["stack_name"], env)
|
stack_deploy(app_name, stack_name, env)
|
||||||
|
|
||||||
return render_template(
|
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
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user