From e1e9c0e42ecad813a51258f9146691c9b6712c71 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Mon, 8 Aug 2022 22:52:17 +0200 Subject: [PATCH] Adjust deploy.py --- podman/deploy.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/podman/deploy.py b/podman/deploy.py index 06ebc80..8b158ee 100755 --- a/podman/deploy.py +++ b/podman/deploy.py @@ -13,6 +13,10 @@ VOLUMES_DIR = Path.home() / "volumes" # AdvLabDB ADVLABDB_REPO_LINK = "https://gitlab.rlp.net/mobitar/advlabdb.git" ADVLABDB_VOLUMES_DIR = VOLUMES_DIR / "advlabdb" +# TODO: Do not mount the repo. +# TODO: Mount volume for data. +# TODO: Use environment variable for config dir. +# TODO: Mount volume for settings and secrets. ADVLABDB_REPO_DIR = ADVLABDB_VOLUMES_DIR / "repo" ADVLABDB_LOGS_DIR = ADVLABDB_VOLUMES_DIR / "logs" # Traefik @@ -102,7 +106,7 @@ def create_container(container_name: str, podman_args: str): # Checking requirements -env_file = ADVLABDB_REPO_DIR / ".env" +settings_file = ADVLABDB_REPO_DIR / "settings.ini" if ADVLABDB_REPO_DIR.is_dir(): print("Pulling AdvLabDB repository.") @@ -112,8 +116,8 @@ if ADVLABDB_REPO_DIR.is_dir(): check=True, ) - if not env_file.is_file(): - sys.exit(f"{env_file} missing!") + if not settings_file.is_file(): + sys.exit(f"{settings_file} missing!") else: if args.verbose: print(f"Making sure that the volumes directory {ADVLABDB_VOLUMES_DIR} exists.") @@ -126,7 +130,7 @@ else: f"git clone {ADVLABDB_REPO_LINK} {ADVLABDB_REPO_DIR}", check=True, ) - sys.exit(f"{env_file} missing!") + sys.exit(f"{settings_file} missing!") if not args.skip_traefik: if not TRAEFIK_ETC_DIR.is_dir(): @@ -156,15 +160,14 @@ run( print("Creating AdvLabDB image.") commands = [ - # TODO: Use fixed version tag 3.10-slim - "buildah from --pull --name builder docker.io/library/python:slim", + "buildah from --pull --name builder docker.io/library/python:3.10-slim", # Copy repo into container f"buildah copy builder {ADVLABDB_REPO_DIR} /volumes/repo", "buildah config --workingdir /volumes/repo builder", # Install Python requirements in the container "buildah run builder -- pip3 install -r requirements.txt", - # TODO: Only when database does not exist - "buildah run builder -- python3 -m advlabdb.scripts.setup.init_database", + "buildah run builder -- python3 manage.py setup generate-secrets", + "buildah run builder -- python3 manage.py setup initialize-database", "buildah config --cmd 'gunicorn --bind 0.0.0.0:80 --workers 5 --log-file /volumes/logs/gunicorn.log run:app' builder", ]