Introduction
SERMAS runs as a set of services: the API, the kiosk, Keycloak, an MQTT broker, MongoDB, Redis, ChromaDB, an S3-compatible object store, speechbrain and, optionally, local speech services. sermas-toolkit-api runs them on one machine from the released images (see System setup).
Internal service communication
In that setup every service publishes its port on the host, and every reference from
one service to another goes through the docker host, 172.17.0.1:<port>. The proxy
(Caddy, port 8080) is the single entry point: /api to the API (3000), /keycloak to
Keycloak, /mqtt to the broker's websocket, everything else to the kiosk (3001).
The browser is the exception: it uses http://localhost:8080, because the microphone
and the camera need a secure origin.
The further you depart from this setup (several machines, Kubernetes), the more URLs you set through environment variables, and the more connectivity you ensure between the services.
Exposing the setup on a domain
Assuming:
- the machine is reachable from the internet on ports 80 and 443
- a domain points to it, for example
mysermas.com
Configure the Caddy proxy
Add a site block for the domain to config/proxy/Caddyfile; Caddy obtains the TLS
certificate itself:
mysermas.com {
route /mqtt* {
uri strip_prefix /mqtt
reverse_proxy mqtt:1884
}
route /.well-known/sermas.json {
rewrite /.well-known/sermas.json /api/.well-known/sermas.json
}
route /keycloak* {
reverse_proxy keycloak:8080
}
route /api* {
reverse_proxy 172.17.0.1:3000
}
route /* {
reverse_proxy 172.17.0.1:3001
}
}
Do not expose /keycloak-admin or /minio-admin publicly.
Expose ports 80 and 443, and keep the certificates
In docker-compose.yaml, on the proxy service:
proxy:
# ...
ports:
- 8080:8080
- 80:80
- 443:443
volumes:
# ...
- ./data/caddy:/data
Update the URLs
In config/api/.env:
API_URL=https://mysermas.com
AUTH_KEYCLOAK_FRONTEND_URL=https://mysermas.com/keycloak
In config/kiosk/.env, the values the browser uses:
PUBLIC_TOOLKIT_URL=https://mysermas.com
PUBLIC_AUTH_URL=https://mysermas.com/keycloak
Keycloak must know its public name too: set KC_HOSTNAME: https://mysermas.com/keycloak
on the keycloak service.
Advanced deployment configuration
Follow this section if you deploy the SERMAS services under URLs different from the default ones.
API configuration
Read here for the API env configurations options.
Kiosk configuration
The Kiosk is a browser-based web application. It uses camera and video access, thus it require a secure context to work.
By default, it works on localhost:8080. localhost is considered a secure context mostly for development activities.
To serve the kiosk on the network or over a website, we need to add some additional configuration.
Follow the configuration needed to serve from an IP in the local network. We will use sermas.lan as a placeholder (but could be an IP).
PUBLIC_TOOLKIT_URL=http://sermas.lan:8080PUBLIC_AUTH_URL=http://sermas.lan:8080/keycloakPRIVATE_API_BASE_URL=http://sermas.lan:8080/api(the kiosk's server side)
Note The kiosk on a local network should still run in localhost to ensure microphone and camera access. Alternatively, the system should be exposed on the web over https.
Without Keycloak
For a single-instance demo, AUTH_PROVIDER=local makes the API issue and verify its own
tokens: no Keycloak and no user management. The clients and one administrator come from
the API's configuration, and the signing key lives in memory, so a restart logs everyone
out. The commented block "Without Keycloak" in config/api/.env.example (and its
counterpart in the kiosk's example) lists the settings. Use Keycloak for anything with
real users.
Securing the setup
Some defaults simplify development and must be changed in a real deployment.
API (config/api/.env)
ADMIN_USER,ADMIN_PASSWORD: the platform administrator (defaultadmin/admin)ADMIN_SERVICE_ACCOUNT_USERNAME,ADMIN_SERVICE_ACCOUNT_PASSWORD: Keycloak's administrator (defaultadmin/admin); matchKC_BOOTSTRAP_ADMIN_*on thekeycloakserviceAUTH_KEYCLOAK_SECRET: the secret of theplatformclient, which administers the realm (defaultplatform)AUTH_KEYCLOAK_KIOSK_CLIENT_SECRET: the kiosk's own client, which may only mint app tokens
Kiosk (config/kiosk/.env)
PRIVATE_AUTH_CLIENT_ID=kioskandPRIVATE_AUTH_CLIENT_SECRET: the same secret asAUTH_KEYCLOAK_KIOSK_CLIENT_SECRET. Left empty, the kiosk falls back to theplatformclient, a Keycloak administrator: do not do that in production.PUBLIC_AUTH_REALM: the API'sAUTH_KEYCLOAK_REALM