You must build the docker image provided in this directory by using the following command:
mvn clean install
This project will also generate Docker standalone project files in target/filtered-docker as well as position the required Unomi tarball.
Unomi requires a search engine (ElasticSearch or OpenSearch) so it is recommended to run Unomi and the search engine using docker-compose.
Set admin and health passwords first (required; no known defaults are shipped):
export UNOMI_ROOT_PASSWORD='choose-a-strong-password' export UNOMI_HEALTHCHECK_PASSWORD='choose-a-strong-health-password' mvn docker:start
You will need to wait while Docker builds the containers and they boot up (the search engine will take a minute or two). Once they are up you can check that the Unomi services are available by visiting http://localhost:8181 in a web browser.
If you want to run it without docker-compose you should then make sure you setup the following environments properly.
For ElasticSearch:
docker pull docker.elastic.co/elasticsearch/elasticsearch:9.4.3 docker network create unomi docker run -d --name elasticsearch --net unomi -p 9200:9200 -p 9300:9300 \ -e "discovery.type=single-node" \ -e "xpack.security.enabled=false" \ -e cluster.name=contextElasticSearch \ docker.elastic.co/elasticsearch/elasticsearch:9.4.3
For OpenSearch:
docker pull opensearchproject/opensearch:3.7.0 docker network create unomi export OPENSEARCH_ADMIN_PASSWORD=enter_your_custom_admin_password_here docker run -d --name opensearch --net unomi -p 9200:9200 -p 9300:9300 \ -e "discovery.type=single-node" \ -e OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_ADMIN_PASSWORD} \ opensearchproject/opensearch:3.7.0
For Unomi (with ElasticSearch):
docker pull apache/unomi:4.0.0-SNAPSHOT docker run -d --name unomi --net unomi -p 8181:8181 -p 9443:9443 -p 8102:8102 \ -e UNOMI_ROOT_PASSWORD='choose-a-strong-password' \ -e UNOMI_HEALTHCHECK_PASSWORD='choose-a-strong-health-password' \ -e UNOMI_ELASTICSEARCH_ADDRESSES=elasticsearch:9200 \ apache/unomi:4.0.0-SNAPSHOT
For Unomi (with OpenSearch):
docker pull apache/unomi:4.0.0-SNAPSHOT docker run -d --name unomi --net unomi -p 8181:8181 -p 9443:9443 -p 8102:8102 \ -e UNOMI_ROOT_PASSWORD='choose-a-strong-password' \ -e UNOMI_HEALTHCHECK_PASSWORD='choose-a-strong-health-password' \ -e UNOMI_DISTRIBUTION=unomi-distribution-opensearch \ -e UNOMI_OPENSEARCH_ADDRESSES=opensearch:9200 \ -e UNOMI_OPENSEARCH_PASSWORD=${OPENSEARCH_ADMIN_PASSWORD} \ apache/unomi:4.0.0-SNAPSHOT
For ElasticSearch:
docker run -d --name unomi -p 8181:8181 -p 9443:9443 -p 8102:8102 \ -e UNOMI_ROOT_PASSWORD='choose-a-strong-password' \ -e UNOMI_HEALTHCHECK_PASSWORD='choose-a-strong-health-password' \ -e UNOMI_ELASTICSEARCH_ADDRESSES=host.docker.internal:9200 \ apache/unomi:4.0.0-SNAPSHOT
For OpenSearch:
docker run -d --name unomi -p 8181:8181 -p 9443:9443 -p 8102:8102 \ -e UNOMI_ROOT_PASSWORD='choose-a-strong-password' \ -e UNOMI_HEALTHCHECK_PASSWORD='choose-a-strong-health-password' \ -e UNOMI_DISTRIBUTION=unomi-distribution-opensearch \ -e UNOMI_OPENSEARCH_ADDRESSES=host.docker.internal:9200 \ -e UNOMI_OPENSEARCH_PASSWORD=${OPENSEARCH_ADMIN_PASSWORD} \ apache/unomi:4.0.0-SNAPSHOT
Note: Linux doesn't support the host.docker.internal DNS lookup method yet, it should be available in an upcoming version of Docker. See https://github.com/docker/for-linux/issues/264
UNOMI_ROOT_PASSWORD: Required admin (karaf) password — no known defaultUNOMI_HEALTHCHECK_PASSWORD: Required health-check (health) password — no known defaultUNOMI_HEALTHCHECK_ENABLED: Register /health/check (true by default). false turns the endpoint off; authentication cannot be disabledUNOMI_HEALTHCHECK_PROVIDERS: Comma-separated provider list (defaults come from the cfg for Elasticsearch or OpenSearch)UNOMI_HEALTHCHECK_TIMEOUT: Per-provider timeout in milliseconds (default 400, range 1–60000)UNOMI_CLUSTER_NODEID: Optional node id, unique per container. When unset, Unomi generates one on the first start and stores it inside the container; set this variable to keep the same id when the container is recreatedUNOMI_CLUSTER_NODENAME: Optional user friendly node name (defaults to the container host name); it is the prefix of a generated idUNOMI_AUTO_START: Boolean to specify if unomi auto start with karaf (defaults to true)UNOMI_DISTRIBUTION: Specifies the Unomi Distribution Feature to use (unomi-distribution-elasticsearch or unomi-distribution-opensearch, defaults to unomi-distribution-elasticsearch)UNOMI_PUBLIC_CORS_ALLOWED_ORIGINS: Comma-separated website origins (https://www.example.com) that may use the visitor cookie with every tenant's key (default: none)UNOMI_PUBLIC_CORS_TENANT_ORIGINS: Whether each tenant may list its own websites in its publicCorsAllowedOrigins property (default: true; only false turns it off)UNOMI_PUBLIC_CORS_MATCH_REFERER: Recognise a listed website that embeds context.js with a <script> tag by its Referer (default: false)UNOMI_PROFILE_COOKIE_SAMESITE: Lax (default), Strict or None; None needs HTTPSSee “Websites on other origins” in the manual's configuration chapter.
UNOMI_REST_AUTHENTICATION_DEFAULTTENANTID: Tenant used when a JAAS admin request has no X-Unomi-Tenant-Id header (default: default). Not used by single-tenant compatibility mode yet, which always runs REST requests on defaultUNOMI_TENANT_APIKEY_REFRESH_INTERVAL: How often, in milliseconds, each node reloads its list of API keys to pick up keys created on other nodes (default: 30000)UNOMI_TENANT_APIKEY_MISS_REFRESH_INTERVAL: Minimum time, in milliseconds, between reloads triggered by unknown keys (default: 5000)Revoked, replaced and expired keys are refused at once on every node whatever these are set to. See “When a key change takes effect” in the manual's multi-tenancy chapter.
UNOMI_ELASTICSEARCH_ADDRESSES: ElasticSearch host:port (default: localhost:9200)UNOMI_ELASTICSEARCH_USERNAME: Optional username for ElasticSearchUNOMI_ELASTICSEARCH_PASSWORD: Optional password for ElasticSearchUNOMI_ELASTICSEARCH_SSL_ENABLE: Enable SSL for ElasticSearch connection (default: false)UNOMI_OPENSEARCH_ADDRESSES: OpenSearch host:port (default: localhost:9200)UNOMI_OPENSEARCH_PASSWORD: Required admin password for OpenSearch (SSL and authentication are mandatory)Multi-tenancy requires a tenant before client endpoints such as /cxs/context.json accept traffic:
curl -X POST http://localhost:8181/cxs/tenants \ --user "karaf:${UNOMI_ROOT_PASSWORD}" \ -H "Content-Type: application/json" \ -d '{"requestedId":"default","properties":{"name":"Default Tenant"}}'
Save the public and private API keys from the response. Use the public key in the X-Unomi-Api-Key header for public endpoints.
See the Multi-tenancy chapter in the manual for details.
If you want to rebuild the images or use docker compose directly, you must still first use mvn clean install to generate the filtered project in target/filtered-docker.
You can then use docker compose -f docker-compose-es.yml up to start the project with ElasticSearch or docker compose -f docker-compose-os.yml up to start the project with OpenSearch.