Commit 44f94be9f2aa3a15a0f80fe7b05a79fb3f0f98b8

Authored by Alexis Koralewski
1 parent 0e621584
Exists in dev

add hostname environment variable for pyros (django settings)

docker/.env-sample
... ... @@ -9,14 +9,16 @@
9 9  
10 10 # === MySQL variables (change them only if you do not use Docker)
11 11 # any value as password without any space
12   -MYSQL_ROOT_PASSWORD=root
  12 +MYSQL_ROOT_PASSWORD = root
13 13 # define the name of the root account (when not using Docker)
14   -MYSQL_ROOT_LOGIN=root
  14 +MYSQL_ROOT_LOGIN = root
15 15 # define mysql tcp port (default is 3306)
16   -MYSQL_TCP_PORT=3306
  16 +MYSQL_TCP_PORT = 3306
17 17 # define login for superadmin user
18   -MYSQL_PYROS_LOGIN=pyros
  18 +MYSQL_PYROS_LOGIN = pyros
19 19 # define password for superadmin user
20   -MYSQL_PYROS_PWD=DjangoPyros
  20 +MYSQL_PYROS_PWD = DjangoPyros
21 21 # Define the local port where you will access the website. When using Docker, we will bind the same port within the docker network and your local port.
22   -PYROS_WEBSITE_PORT=8000
23 22 \ No newline at end of file
  23 +PYROS_WEBSITE_PORT = 8000
  24 +# Host name
  25 +HOST_NAME = localhost
... ...
src/core/pyros_django/pyros/settings.py
... ... @@ -146,13 +146,14 @@ MYSQL_PORT = "3306"
146 146 SQL_USER = ""
147 147 SQL_PWD = ""
148 148 #PATH_TO_OBSCONF_FILE = os.path.join(BASE_DIR,"../../privatedev/config/default/observatory_default.yml")
149   -
  149 +HOST = os.environ["HOST_NAME"]
150 150 ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'pyros.irap.omp.eu', 'astroguita.hd.free.fr', '0.0.0.0']
151 151 # defining variables when using Docker
152 152 if WITH_DOCKER:
153 153 ALLOWED_HOSTS.append('0.0.0.0')
154 154 HTTP_PORT = ":8000"
155   -
  155 +if HOST:
  156 + ALLOWED_HOSTS.append(HOST)
156 157 try:
157 158 MYSQL_PORT = os.environ['MYSQL_TCP_PORT'].strip()
158 159 SQL_USER = os.environ["MYSQL_PYROS_LOGIN"].strip()
... ... @@ -429,7 +430,7 @@ python_version = subprocess.run( "python --version | cut -d ' ' -f 2 | cut -d '.
429 430 python_version = python_version.stdout
430 431 day = "2022-01-06"
431 432 django_version_major,django_version_minor = django.VERSION[:2][0],django.VERSION[:2][1]
432   -pyros_version = read_version_number_from_file("../../../VERSION")
  433 +pyros_version = read_version_number_from_file(f"{BASE_DIR}/../../../VERSION")
433 434 #TODO: create function to read VERSION file
434 435  
435 436 #pyros_version = "0.2.12.0"
... ...