mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Separate nginx container
This commit is contained in:
parent
3f8a5e0b4f
commit
9bc1a334be
2 changed files with 19 additions and 23 deletions
|
@ -16,13 +16,13 @@ ADVLABDB_VOLUMES_DIR = VOLUMES_DIR / "advlabdb"
|
||||||
ADVLABDB_REPO_DIR = ADVLABDB_VOLUMES_DIR / "repo"
|
ADVLABDB_REPO_DIR = ADVLABDB_VOLUMES_DIR / "repo"
|
||||||
ADVLABDB_LOGS_DIR = ADVLABDB_VOLUMES_DIR / "logs"
|
ADVLABDB_LOGS_DIR = ADVLABDB_VOLUMES_DIR / "logs"
|
||||||
ADVLABDB_DATA_DIR = ADVLABDB_VOLUMES_DIR / "data"
|
ADVLABDB_DATA_DIR = ADVLABDB_VOLUMES_DIR / "data"
|
||||||
|
# Nginx
|
||||||
|
NGINX_CONF_D_DIR = ADVLABDB_VOLUMES_DIR / "nginx/conf.d"
|
||||||
# Traefik
|
# Traefik
|
||||||
TRAEFIK_VOLUMES_DIR = VOLUMES_DIR / "traefik"
|
TRAEFIK_VOLUMES_DIR = VOLUMES_DIR / "traefik"
|
||||||
TRAEFIK_ETC_DIR = TRAEFIK_VOLUMES_DIR / "etc"
|
TRAEFIK_ETC_DIR = TRAEFIK_VOLUMES_DIR / "etc"
|
||||||
TRAEFIK_LOGS_DIR = TRAEFIK_VOLUMES_DIR / "logs"
|
TRAEFIK_LOGS_DIR = TRAEFIK_VOLUMES_DIR / "logs"
|
||||||
TRAEFIK_CERTS_DIR = TRAEFIK_VOLUMES_DIR / "certs"
|
TRAEFIK_CERTS_DIR = TRAEFIK_VOLUMES_DIR / "certs"
|
||||||
# Nginx
|
|
||||||
NGINX_CONF_D_DIR = VOLUMES_DIR / "nginx/conf.d"
|
|
||||||
# Systemd
|
# Systemd
|
||||||
SYSTEMD_USER_DIR = Path.home() / ".config/systemd/user"
|
SYSTEMD_USER_DIR = Path.home() / ".config/systemd/user"
|
||||||
|
|
||||||
|
@ -37,11 +37,6 @@ parser.add_argument(
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Do not deploy the Traefik container.",
|
help="Do not deploy the Traefik container.",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"--skip-nginx",
|
|
||||||
action="store_true",
|
|
||||||
help="Do not deploy the Nginx container.",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-n",
|
"-n",
|
||||||
"--network",
|
"--network",
|
||||||
|
@ -127,14 +122,13 @@ def check_requirements():
|
||||||
if not settings_file.is_file():
|
if not settings_file.is_file():
|
||||||
sys.exit(f"{settings_file} missing!")
|
sys.exit(f"{settings_file} missing!")
|
||||||
|
|
||||||
|
if not NGINX_CONF_D_DIR.is_dir():
|
||||||
|
sys.exit(f"{NGINX_CONF_D_DIR} missing!")
|
||||||
|
|
||||||
if not args.skip_traefik:
|
if not args.skip_traefik:
|
||||||
if not TRAEFIK_ETC_DIR.is_dir():
|
if not TRAEFIK_ETC_DIR.is_dir():
|
||||||
sys.exit(f"{TRAEFIK_ETC_DIR} missing!")
|
sys.exit(f"{TRAEFIK_ETC_DIR} missing!")
|
||||||
|
|
||||||
if not args.skip_nginx:
|
|
||||||
if not NGINX_CONF_D_DIR.is_dir():
|
|
||||||
sys.exit(f"{NGINX_CONF_D_DIR} missing!")
|
|
||||||
|
|
||||||
if run(f"podman network exists {args.network}").returncode != 0:
|
if run(f"podman network exists {args.network}").returncode != 0:
|
||||||
if args.skip_traefik:
|
if args.skip_traefik:
|
||||||
sys.exit(f"Skipped Traefik's deployment although Traefik's network {args.network} does not exist!")
|
sys.exit(f"Skipped Traefik's deployment although Traefik's network {args.network} does not exist!")
|
||||||
|
@ -147,6 +141,16 @@ def check_requirements():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def create_nginx_container():
|
||||||
|
create_container(
|
||||||
|
"advlabdb-nginx",
|
||||||
|
f"""--network {args.network} \
|
||||||
|
-v {NGINX_CONF_D_DIR}:/etc/nginx/conf.d:Z,ro \
|
||||||
|
--label "io.containers.autoupdate=registry" \
|
||||||
|
docker.io/library/nginx:alpine""",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_traefik_container():
|
def create_traefik_container():
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
print(f"Making sure that the logs directory {TRAEFIK_LOGS_DIR} exists.")
|
print(f"Making sure that the logs directory {TRAEFIK_LOGS_DIR} exists.")
|
||||||
|
@ -169,16 +173,6 @@ def create_traefik_container():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_nginx_container():
|
|
||||||
create_container(
|
|
||||||
"nginx",
|
|
||||||
f"""--network {args.network} \
|
|
||||||
-v {NGINX_CONF_D_DIR}:/etc/nginx/conf.d:Z,ro \
|
|
||||||
--label "io.containers.autoupdate=registry" \
|
|
||||||
docker.io/library/nginx:alpine""",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Needed for main and create_advlabdb_container
|
# Needed for main and create_advlabdb_container
|
||||||
advlabdb_container_args = f"""--network {args.network} \
|
advlabdb_container_args = f"""--network {args.network} \
|
||||||
-e ADVLABDB_DATA_DIR=/volumes/data \
|
-e ADVLABDB_DATA_DIR=/volumes/data \
|
||||||
|
@ -276,8 +270,10 @@ def main():
|
||||||
|
|
||||||
# Create Nginx container if needed
|
# Create Nginx container if needed
|
||||||
|
|
||||||
if not args.skip_nginx and run("systemctl --user is-enabled container-nginx").returncode != 0:
|
if run("systemctl --user is-enabled container-advlabdb-nginx").returncode != 0:
|
||||||
create_nginx_container()
|
create_nginx_container()
|
||||||
|
else:
|
||||||
|
run("systemctl --user restart container-advlabdb-nginx")
|
||||||
|
|
||||||
print("\nDone!\n")
|
print("\nDone!\n")
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,4 @@ http:
|
||||||
advlabdb:
|
advlabdb:
|
||||||
loadBalancer:
|
loadBalancer:
|
||||||
servers:
|
servers:
|
||||||
- url: http://nginx
|
- url: http://advlabdb-nginx
|
||||||
|
|
Loading…
Reference in a new issue