From 3b8f114788d27f2732fe2127656b04474727e201 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Thu, 18 Aug 2022 19:05:00 +0200 Subject: [PATCH] Create create_advlabdb_container --- podman/deploy.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/podman/deploy.py b/podman/deploy.py index cef5e5f..ce692e7 100755 --- a/podman/deploy.py +++ b/podman/deploy.py @@ -179,6 +179,21 @@ def create_nginx_container(): ) +# Needed for main and create_advlabdb_container +advlabdb_container_args = f"""--network {args.network} \ + -e ADVLABDB_DATA_DIR=/volumes/data \ + -v {ADVLABDB_REPO_DIR}:/volumes/repo:Z \ + -v {ADVLABDB_DATA_DIR}:/volumes/data:Z \ + -v {ADVLABDB_LOGS_DIR}:/volumes/logs:Z""" + + +def create_advlabdb_container(): + create_container( + "advlabdb", + f"{advlabdb_container_args} localhost/advlabdb:latest", + ) + + def main(): pull_or_clone_repo() @@ -240,14 +255,8 @@ def main(): print(f"Making sure that the logs directory {ADVLABDB_LOGS_DIR} exists.") ADVLABDB_LOGS_DIR.mkdir(parents=True, exist_ok=True) - container_args = f"""--network {args.network} \ - -e ADVLABDB_DATA_DIR=/volumes/data \ - -v {ADVLABDB_REPO_DIR}:/volumes/repo:Z \ - -v {ADVLABDB_DATA_DIR}:/volumes/data:Z \ - -v {ADVLABDB_LOGS_DIR}:/volumes/logs:Z""" - # Running setup commands (if needed) - run_manage = f"podman run -it --rm {container_args} localhost/advlabdb:latest python3 manage.py" + run_manage = f"podman run -it --rm {advlabdb_container_args} localhost/advlabdb:latest python3 manage.py" commands = ( # Generate secret keys if secrets.ini does not exist yet f"{run_manage} setup generate-secrets", @@ -258,10 +267,7 @@ def main(): for command in commands: run(command, check=True) - create_container( - "advlabdb", - f"{container_args} localhost/advlabdb:latest", - ) + create_advlabdb_container() # Create Traefik container if needed