mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2025-03-31 20:33:55 +00:00
Adjust deploy.py
This commit is contained in:
parent
693e72f4c0
commit
e1e9c0e42e
1 changed files with 11 additions and 8 deletions
|
@ -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",
|
||||
]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue