Commit 3e125e8f4908fc1633953063532a28c62be7a152
1 parent
b755ff73
Exists in
dev
Add webport personnalisation, fixing issue with environment variables used for ConfigPyros
Showing
5 changed files
with
15 additions
and
7 deletions
Show diff stats
docker/.env-sample
... | ... | @@ -19,4 +19,4 @@ MYSQL_PYROS_LOGIN=pyros |
19 | 19 | # define password for superadmin user |
20 | 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=8080 | |
23 | 22 | \ No newline at end of file |
23 | +PYROS_WEBSITE_PORT=8000 | |
24 | 24 | \ No newline at end of file | ... | ... |
docker/PYROS_DOCKER_SHELL
docker/PYROS_DOCKER_TEST
docker/docker-compose.yml
... | ... | @@ -46,7 +46,7 @@ services: |
46 | 46 | - ..:/home/pyros_user/app |
47 | 47 | # tells which port of local machine can communicate with the docker image (host:container), host is your local machine |
48 | 48 | ports: |
49 | - - "8000:8000" | |
49 | + - "${PYROS_WEBSITE_PORT:-8000}:${PYROS_WEBSITE_PORT:-8000}" | |
50 | 50 | # starting db service before install service |
51 | 51 | depends_on: |
52 | 52 | - db | ... | ... |
pyros.py
... | ... | @@ -321,11 +321,17 @@ def set_environment_variables_if_not_configured(env_path: str,env_sample_path: s |
321 | 321 | line = line.rstrip() |
322 | 322 | key,value = line.split("=") |
323 | 323 | # setting variables as environment variables |
324 | - if WITH_DOCKER and os.environ[key] != value: | |
324 | + if not WITH_DOCKER and os.environ.get(key) is None: | |
325 | + print(f"ERROR: Error while reading value for '{key}'.Please fix the '{env_file}' file. For this run, PyROS will take the values from '{env_path}'") | |
326 | + raise BaseException() | |
327 | + if WITH_DOCKER and os.environ.get(key) is None: | |
328 | + print(f"WARNING: Environment value for '{key}' isn't defined within the container (To remove this message : restart docker container to update environment values). PyROS will take the values from '{env_path}'") | |
329 | + raise BaseException() | |
330 | + if WITH_DOCKER and os.environ.get(key) != value: | |
325 | 331 | print(f"WARNING: Environment value for '{key}' needs to be uptaded (To remove this message : restart docker container to update them). PyROS will take the value from '{env_path}'") |
326 | 332 | os.environ[key] = value |
327 | 333 | except: |
328 | - print(f".env not found at {env_path} or is empty, creating a file at this path from the .env-sample file stored at {ENV_SAMPLE_PATH}\nvalues from .env-sample will be used as environment variables") | |
334 | + #print(f".env not found at {env_path} or is empty, creating a file at this path from the .env-sample file stored at {ENV_SAMPLE_PATH}\nvalues from .env-sample will be used as environment variables") | |
329 | 335 | with open(env_sample_path,'r') as env_sample_file: |
330 | 336 | with open(env_path,"w") as env_file: |
331 | 337 | for env_sample_line in env_sample_file: |
... | ... | @@ -517,7 +523,9 @@ def test(app): |
517 | 523 | |
518 | 524 | #start_dir = os.getcwd() |
519 | 525 | if app == None: |
520 | - apps = ['obsconfig','scientific_program','common', 'scheduler', 'routine_manager', 'user_manager', 'alert_manager.tests.TestStrategyChange'] | |
526 | + #apps = ['obsconfig','scientific_program','common', 'scheduler', 'routine_manager', 'user_manager', 'alert_manager.tests.TestStrategyChange'] | |
527 | + # Removing temporiraly scientific_program and alert_manager from tests | |
528 | + apps = ['obsconfig','common', 'scheduler', 'routine_manager', 'user_manager'] | |
521 | 529 | else: |
522 | 530 | os.environ["PATH_TO_OBSCONF_FILE"] = os.path.join(os.path.abspath(PYROS_DJANGO_BASE_DIR),"obsconfig/fixtures/observatory_configuration_ok_simple.yml") |
523 | 531 | change_dir(PYROS_DJANGO_BASE_DIR) | ... | ... |