Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion documentation/deployment_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ The full list of settings is as follows:
| `POSTGRES_PASSWORD` | The password for Postgres access. This should be set to `'postgres'`. |
| `POSTGRES_PORT` | The port through which the Postgres is exposed. This should be set to `5432`. |
| `API_BASE_URL` | The URL and port by which the QCrBox tool manager can be accessed. If QCrBox is installed on the same machine as this setup, this should be set to `'http://host.docker.internal:11000'`. |
| `API_VISUALISER_PORT` | The port through which the QCrBox_quality visualiser can be accessed. This should be set to `12008` in most cases. |
| `TRAEFIK_HTTP_PORT` | The port through which the Traefik router (which handles GUI routing) is exposed. For development, this should be set to `12345`. |
| `GUI_DOMAIN_PREFIX` | The prefix for GUI subdomains. This should be set to `.gui.` for default setups. |
| `MAX_LENGTH_API_LOG` | The maximum length of API output to be saved in the logs. As some API outputs can be quite long, this gives the option to truncate them in the logs, making the logs more unwieldy at the cost of losing some debug information. |
| `DJANGO_SUPERUSER_EMAIL` | The email address for the default admin account to be created for the web app. |
| `DJANGO_SUPERUSER_USERNAME` | The username for the default admin account to be created for the web app. |
Expand Down
3 changes: 2 additions & 1 deletion environment.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ POSTGRES_PASSWORD='postgres'
POSTGRES_PORT=5432

API_BASE_URL='http://host.docker.internal:11000'
API_VISUALISER_PORT='12008'
TRAEFIK_HTTP_PORT='12345'
GUI_DOMAIN_PREFIX='.gui.'

MAX_LENGTH_API_LOG=10000

Expand Down
5 changes: 4 additions & 1 deletion qcrbox_frontend/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@

# API settings
API_BASE_URL = os.environ.get('API_BASE_URL', 'http://127.0.0.1:11000')
API_VISUALISER_PORT = os.environ.get('API_VISUALISER_PORT', '12008')

# Traefik / GUI Routing settings
TRAEFIK_HTTP_PORT = int(os.environ.get('TRAEFIK_HTTP_PORT', '12345') or 12345)
GUI_DOMAIN_PREFIX = os.environ.get('GUI_DOMAIN_PREFIX', '.gui.')

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
Expand Down
8 changes: 7 additions & 1 deletion qcrbox_frontend/qcrbox/templates/workflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,14 @@ <h5><b><i>Calculation in progress, do not close this tab!</i></b></h5>
{% if current_command.interactive %}
<script>
let hostname = window.location.hostname;
let appSlug = "{{ current_command.app.slug }}".replace(/_/g, "-");
let domainPrefix = "{{ gui_domain_prefix }}";
let port = "{{ traefik_port }}";
let portSuffix = port ? ":" + port : "";

let url = `http://${appSlug}${domainPrefix}${hostname}${portSuffix}/`;

document.getElementById("start-app-button").addEventListener("click", function(){ window.open(`http://${hostname}:{{ current_command.app.port }}/vnc.html?path=vnc&autoconnect=true&resize=remote&reconnect=true&show_dot=true`, '_blank'); });
document.getElementById("start-app-button").addEventListener("click", function(){ window.open(url, '_blank'); });
</script>
{% elif calculation_in_progress %}
<script>
Expand Down
11 changes: 9 additions & 2 deletions qcrbox_frontend/qcrbox/views/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,15 @@ def visualise(request, dataset_id):

# Get host name without port, manually prepend http:// to stop django
# treating this as a relative URL
hostname = 'http://' + request.get_host().split(':')[0]
v_url = f'{hostname}:{settings.API_VISUALISER_PORT}/retrieve/{visualise_file_meta.backend_uuid}'
hostname = request.get_host().split(':')[0]

# Construct the visualiser domain URL
# Format: http://[app-slug].gui.[hostname]:[traefik-port]/
visualiser_domain = f'qcrbox-quality{settings.GUI_DOMAIN_PREFIX}{hostname}'

port_suffix = f':{settings.TRAEFIK_HTTP_PORT}' if settings.TRAEFIK_HTTP_PORT else ''

v_url = f'http://{visualiser_domain}{port_suffix}/retrieve/{visualise_file_meta.backend_uuid}'
LOGGER.info(
'Opening Visualiser at "%s"',
v_url,
Expand Down
4 changes: 4 additions & 0 deletions qcrbox_frontend/qcrbox/views/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ def workflow(request, file_id):
else:
context['app_session_id'] = None

# Pass Traefik config to template
context['traefik_port'] = settings.TRAEFIK_HTTP_PORT
context['gui_domain_prefix'] = settings.GUI_DOMAIN_PREFIX

return render(request, 'workflow.html', context)


Expand Down