Deploy a TRE Agent and Data Egress
This page contains:
- a summary of what is involved when deploying a Five Safes TES TRE Layer
- a Sample Deployment Guide
- with recommendations for deploying in Production
Component Summary
Here is a summary of the required components which make up the TRE Layer:
| Component | Notes |
|---|---|
| KeyCloak | The TRE Agent and Egress apps each require a Keycloak realm containing users and clients authorised to access them |
| Minio | An Amazon S3 compatible TRE Storage service |
| RabbitMQ | A message broker used for queueing |
| PostgreSQL | A database for the TRE Agent and Egress apps to keep local state |
| Hashicorp Vault | Used for accessing ephemeral credentials as secrets |
| OpenLDAP | Used to provide ephemeral credentials for Trino (if in use as a datasource) |
| Camunda Connectors | A REST API allowing other services (e.g. TRE Agent) to integrate with Camunda |
| Camunda Orchestration | A consolidated service that combines Camunda functionality via Zeebe + Operate + Tasklist |
| ElasticSearch | Used for Camunda’s local datastore such as workflow state |
| TRE-Camunda | A service defining the handlers for ephemeral credentials management. Registers the handlers with Camunda, via Zeebe |
| TRE Agent API | A REST API for TRE Agent functionality |
| TRE Agent GUI | A Web Frontend for TRE Admins to log into and interact with the TRE Agent |
| Egress API | A REST API for Egress Portal functionality |
| Egress GUI | A Web Frontend for Egress Officers to log into and interact with the Egress Portal |
| TES Backend | A standard GA4GH TES implementation to execute the analysis |
You may choose how to distribute your own deployment of these components, as long as they are able to communicate with each other over the network.
For some components, such as KeyCloak or MinIO, you may wish to use your own existing deployments.
User accessible components
A subset of the components will need to be accessible by users, outside of the TRE Layer environent:
| Component | Reason |
|---|---|
| KeyCloak | So that users can authenticate and admins can manage the TRE Agent and Egress KeyCloak Realms |
| TRE Agent GUI | So that TRE Admins can log into and interact with the TRE Agent |
| TRE Agent API | So that TRE Agent GUI browser functionality, and optionally other services, can interact with the TRE Agent REST API |
| Egress GUI | So that Egress Officers can log into and interact with the Egress Portal |
| Egress API | Optional. So that other services can integrate with the Egress REST API |
Sample Deployment Guide
Note that this guide is a sample. It can be modified to reflect the your own infrastructure and configuration choices.
This guide deploys all the components of the TRE Layer (except the TES Backend) on a single host (e.g. a Virtual Machine) using Docker Compose.
All the components are deployed on suitable Docker networks and can communicate with each other as required.
It also automatically configures the necessary KeyCloak realms, ready for following our other guides.
Because the TES Backend is not part of this deployment, it will need to be deployed separately and configured to communicate with the required components.
We also provide guidance for installing Funnel as a TES Backend.
User accessible components
Components which may need to be accessed from outside the host are forwarded to the host on specific ports
| Component | Ports |
|---|---|
| KeyCloak | HTTP: 8085 |
| TRE Agent GUI | HTTP: 8989 |
| TRE Agent API | HTTP: 8072 |
| Egress GUI | HTTP: 8100 |
| Egress API | HTTP: 8101 |
In this sample, where the TES Backend is deployed elsewhere, the TES Backend will also need access to some components:
| Component | Ports |
|---|---|
| MinIO | API HTTP: 9002 |
| TRE Agent API | HTTP: 8072 |
Remember the TES Backend’s environment will also need network access to project data sources, in order for analysis to run against them.
This sample also includes some additional components useful for diagnostic purposes:
| Component | Notes | Ports |
|---|---|---|
| Seq | Logs aggregator and web-based viewer | HTTP: 5341 |
| Adminer | Web-based PostgreSQL client | HTTP: 8087 |
Production Recommendations
To use this sample as a starting point for a production deployment, some general recommendations should be considered.
The ports specified above can be used for configuring a reverse proxy for access to the necessary components.
If you are doing reverse proxy for MinIO, the Websockets Support should be
enabled for MinIO GUI Proxy host.
TRE Database
A TRE database is the database which the analysis query runs against.
If a TRE database is deployed in cloud managed instances (for example, AWS RDS, Azure SQL DB Managed Instance, etc.), this 5 Safes TES implementation requires that you set the TRE Agent with the admin credentials of the TRE database, in order to create and revoke ephemeral credentials.
This can be done by setting the environment variables TRE_DATA_USER and TRE_DATA_PASSWORD with the credentials of the user, more details here .
admincredentials are the ones used when creating or setting up the TRE DB instance.- If the TRE decides to use PostgreSQL as the database, version 16 or later is required. Because in Postgres, to revoke a user/role, either
superuseroradmin(in PostgreSQL version 16+) privilege is required. More details here. - A user created with the
CREATEROLEpermission can create ephemeral credentials but cannot revoke them. - In the case where a TRE cannot not use
admincredentials, the TRE database can be hosted in the samepostgresqldatabase instance, which keeps the local state of TRE Agent, and superuser credentials of thepostgresqlcan be used in the environment variablesTRE_DATA_USERandTRE_DATA_PASSWORD.
Get Started
Prerequisites
- Docker and Docker Compose installed. For Linux/Ubuntu VMs, you can follow this guide
- Git installed on your machine.
- TES executing agent (e.g., Funnel) installed and running.
💡
Instructions on how to install Funnel can be found here
Deployment Steps
To deploy a TRE Agent and Data Egress:
Clone the repository
git clone https://github.com/SwanseaUniversityMedical/5S-TES-deployment.gitPrepare the necessary files
To deploy a TRE Agent and Data Egress, we need the following files and directories in 5S-TES-deployment repository:
DeploymentStack/TRE/docker-compose.ymlDeploymentStack/TRE/config/ServiceStack/.env, which needs to be configured with the appropriate environment variables based on theDeploymentStack/TRE/.env.examplefile.
The docker-compose.yml file in the DeploymentStack/TRE/ directory includes the services for the TRE Agent and Data Egress using relative paths to the compose manifests in the ServiceStack/ directory, where they are defined.
If you need to modify the compose manifests or the docker-compose.yml file,
we recommend to move these four components to a separate directory, e.g.,
/srv/tre, and update the relative paths in the docker-compose.yml and CONFIG_PATH in the .env file accordingly
accordingly. When in sync with the remote repository, the local
5S-TES-deployment repository will then only serve as a reference for your
own deployment, rather than the source of truth.
The compose manifests used in the TRE Agent and Data Egress are:
ServiceStack/compose-manifests/applications/tre-layer.ymlwhich defines the TRE Layer services, i.e., TRE Agent API, TRE Agent GUI.ServiceStack/compose-manifests/applications/egress-layer.ymlwhich defines the Data Egress Layer services, i.e., Data Egress API, Data Egress GUI.ServiceStack/compose-manifests/shared/platform.ymlwhich defines the platform services, i.e., PostgreSQL, Adminer, Serilog, RabbitMQ.ServiceStack/compose-manifests/shared/credentials.ymlwhich defines the services for ephemeral credentials, i.e., Camunda, Connectors, Vault, OpenLDAP, LDAP Init, phpLDAPadmin, Elastic Search.ServiceStack/compose-manifests/shared/auth.ymlwhich defines the authentication services, i.e., Keycloak. This is optional and only needed if you want to use Keycloak for authentication internally within the TRE Layer.💡Comment or remove the line
../../ServiceStack/compose-manifests/shared/auth.ymlin thedocker-compose.ymlfile if you don’t want to use it.ServiceStack/compose-manifests/shared/omop-lite.ymlwhich defines the OMOP Lite service, i.e., OMOP Lite. This is optional and only needed if you want to populate a synthetic OMOP CDM for the TRE data.💡Comment or remove the line
../../ServiceStack/compose-manifests/shared/omop-lite.ymlin thedocker-compose.ymlfile if you don’t want to use it.
Configure the .env file
Create a new .env file in the directory where you store the docker-compose.yml file, and configure the environment variables based on the .env.example file in the DeploymentStack/TRE/ directory or here.
The descriptions of the essential environment variables and the guide to set them are as follows:
| Environment Variable | Description |
|---|---|
DEPLOYMENT_VERSION | The version of the TRE Agent app you are deploying. Find the version
here,
between |
PGLOGIN and PGPASSWORD | The admin credentials for the PostgreSQL database used by the TRE Agent. |
SerilogLevel | The Serilog logging level for the TRE Agent. Default is |
EncryptionSettingsKey | The encryption settings (in 16 bytes Base64 String format) for the TRE Agent. They must be set and can be generated using the |
| The credentials for the PostgreSQL database used to hold the TRE data, e.g., OMOP CDM data. Camunda will use these credentials to create the ephemeral user accounts for the TES executing agent (e.g., Funnel) to access the TRE data. |
TreName | The name identifier for this TRE instance. |
KeycloakHostName | The hostname of the Keycloak server, for example, |
TRE_KEYCLOAK_URL | The URL of the TRE Layer’s Keycloak server. For example,
|
SUBMISSION_KEYCLOAK_URL | The URL of the Submission Layer’s Keycloak server. For example,
|
SubmissionAPIAddressURL | The Submission API address URL. For example,
|
TesAPIUrl | Where TESK or Funnel API is hosted. For example,
|
MINIO_TRE_UI_URL | Where the MinIO TRE UI is hosted. For example,
|
MinioTreOpenidSecret | The OpenID secret for the Minio client of Dare-TRE realm. There is a
default value in the realm configuration, but you should regenerate it
for production deployments. Do this by navigating to |
TreMinioAdminUser | The admin user for the TRE Minio server. |
TreMinioAdminPassword | The admin password for the TRE Minio server. |
MinioRootUser | The root user for the Submission Layer Minio server. |
MinioRootPass | The root password for the Submission Layer Minio server. |
submissionMinioUrl | Point to Submission Layer Minio server, used by TRE Agent. For example,
|
submissionMinioAdminConsole | The URL for the Submission Layer’s Minio admin console. For example,
|
TreApiPublicUrl | The public URL for the TRE Agent API. For example,
|
syncSchedule | Sync Projects & Users between TRE & Submission Layer - default every 10 minutes (in minutes). |
scanSchedule | Scan Submission Layer for available submissions - default every 1 minute (in minutes). |
EgressKeyCloakClientUIRedirectURL | The URL for the Egress Layer’s Keycloak redirect URL. For example,
|
EgressKeyCloakSecret | The OpenID secret for the Egress Keycloak client |
SubmissionAPIKeyCloakClientUIRedirectURL | The URL for the Submission API’s Keycloak redirect URL. For example,
|
SubmissionAPIKeyCloakSecret | The OpenID secret for the Submission API Keycloak client
|
TreKeyCloakClientUIRedirectURL | The URL for the TRE UI’s Keycloak redirect URL. For example,
|
TreKeyCloakSecret | The OpenID secret for the TRE UI Keycloak client |
TreAPIKeyCloakClientUIRedirectURL | The URL for the TRE API’s Keycloak redirect URL. For example,
|
TreAPIKeyCloakSecret | The OpenID secret for the TRE API Keycloak client |
BETTER_AUTH_SECRET | Base-64 String for the secret key for the Better Auth service. Only required if you are using the NextJS Agent web app. Generated using the |
BETTER_AUTH_URL | The URL for the Better Auth service. Typically, this is the URL of the Agent Web App. For example,
|
NEXT_PUBLIC_KEYCLOAK_URL | The URL of the Keycloak Client portal. For example,
|
CONFIG_PATH | The path for the to the shared configuration files (e.g., realm config,
ldap, vault, init scripts) for the TRE Layer. Default is
|
Run docker compose
At the directory where docker-compose.yml and .env files are located, run the following command to start the TRE Agent and Data Egress:
docker compose up -dCheck-in
After the containers are up and running (check with docker ps), if you have configured the ports for the TRE Agent components for user accessibility,
you can access the TRE Agent UI and Egress UI by navigating to http://<hostname>:8989 and http://<hostname>:8100, respectively, in your browser.
If you are using the default Keycloak service defined in the ServiceStack/compose-manifests/shared/auth.yml file, you can access the Keycloak Client portal by navigating to port 8085 of the host machine, and
Then, the default to access KeyCloak admin portal are username admin and admin; the default username and password for the TRE Agent and Egress are globaladminuser and password123.
If you encounter the error “Invalid parameter: redirect_uri” from Keycloak when
trying to login into TRE UI or Egress UI, please make sure the redirectURL
environment variables in the .env file, the URL you put on the browser’s
address bar, and the Valid redirect URIs registered in Keycloak’s client
settings are the same. For more details, please refer to the troubleshooting
guide.
Connect TRE Agent to Submission Layer and Egress
TRE and Submission Layer connection
The TRE Agent needs user credentials from the Submission Layer Keycloak to connect to the Submission Layer. This user should be created in the Dare-Control realm with the dare-tre-admin role and group assigned to it.
If you are hosting your own Submission Layer create the user in the Submission Layer Keycloak. Otherwise, the TRE Admin user’s credentials are typically provided by the Submission Layer admin.
Given these credentials, put them in the page Update Submission Credentials in the TRE Agent UI.
TRE and Egress connection
At the page Update Data Egress Credentials in the TRE Agent UI (port 8989 of the host machine), put the credentials of a user with the dare-tre-admin role in the Dare-Egress Keycloak realm.
If you are using the default local Keycloak service defined in the ServiceStack/compose-manifests/shared/auth.yml file, the user already exists and its credentials are:
Username: accessfromtretoegress
Password: password123At the page Update TRE Credentials in the Egress UI (port 8100 of the host machine), put the credentials of a user with the dare-egress-admin role in the Dare-TRE Keycloak realm.
If you are using the default local Keycloak service defined in the ServiceStack/compose-manifests/shared/auth.yml file, the user already exists and its credentials are:
Username: accessfromegresstotre
Password: password123Update DMN rules
At the page DMN Rules in the TRE Agent UI (port 8989 of the host machine), update and deploy the DMN rules to the correct values of the TRE DB credentials.
| Output:tag | Output:value |
|---|---|
| postgresDatabase | ”change to the TREDBDatabase above” |
| postgresServer | ”change to the TREDBHost above” |
| postgresPort | ”change to the TREDBPort above” |
| postgresSchema | ”change to the schema of the OMOP CDM in TRE DB” |
More details can be found in the guide.
Approve projects and memberships
Once a Submission layer Admin has created a Project, assigned Users to the Project and added your TRE to the Project, you need to approve the Project and User Memberships from the TRE Agent UI (port 8989 of the host machine), at the page Projects.
More details can be found in the guide.
Recommended next steps
- Make sure TRE’s containers, database and TES executing agent are running and accessible, then test the system by sending the Hello world submission or submission with basic analysis task from the Submission layer side.
- Add a new user in the
Dare-TREKeycloak realm with appropriate permissions, then use this user credentials to access the TRE Agent UI. - Add a new user in the
Data-EgressKeycloak realm with appropriate permissions, then use this user credentials to access the Egress UI. - Update passwords or secrets for the TRE Agent and Egress, including the Keycloak client secrets, Minio server credentials, etc.
Debugging
If you encounter any issues, you can check the logs of the containers by running the following command:
docker logs <container-name> -fAlternatively, you can check the logs of the stack by accessing port 5341 (Seq service) of the host machine.