get cert file locations from settings in docker build

This commit is contained in:
Josh 2020-12-01 16:10:49 +00:00
parent 584254e6ca
commit d5b9bc2f26
2 changed files with 10 additions and 11 deletions

View File

@ -91,21 +91,17 @@ def reload_nats():
f"{agent.hostname} does not have a user account, NATS will not work"
)
if not settings.DOCKER_BUILD:
domain = settings.ALLOWED_HOSTS[0].split(".", 1)[1]
if hasattr(settings, "CERT_FILE") and hasattr(settings, "KEY_FILE"):
if os.path.exists(settings.CERT_FILE) and os.path.exists(settings.KEY_FILE):
cert_file = settings.CERT_FILE
key_file = settings.KEY_FILE
else:
cert_file = f"/etc/letsencrypt/live/{domain}/fullchain.pem"
key_file = f"/etc/letsencrypt/live/{domain}/privkey.pem"
domain = settings.ALLOWED_HOSTS[0].split(".", 1)[1]
if hasattr(settings, "CERT_FILE") and hasattr(settings, "KEY_FILE"):
if os.path.exists(settings.CERT_FILE) and os.path.exists(settings.KEY_FILE):
cert_file = settings.CERT_FILE
key_file = settings.KEY_FILE
else:
cert_file = f"/etc/letsencrypt/live/{domain}/fullchain.pem"
key_file = f"/etc/letsencrypt/live/{domain}/privkey.pem"
else:
cert_file = f"/opt/tactical/certs/fullchain.pem"
key_file = f"/opt/tactical/certs/privkey.pem"
cert_file = f"/etc/letsencrypt/live/{domain}/fullchain.pem"
key_file = f"/etc/letsencrypt/live/{domain}/privkey.pem"
config = {
"tls": {

View File

@ -69,6 +69,9 @@ DEBUG = False
DOCKER_BUILD = True
CERT_FILE = '/opt/tactical/certs/fullchain.pem'
CERT_KEY = '/opt/tactical/certs/privkey.pem'
SCRIPTS_DIR = '/opt/tactical/scripts'
ALLOWED_HOSTS = ['${API_HOST}']