Optimize in docker examples?

Can anyone share reference implementation of a dockerfile to start up Camunda Optimize in a docker container? I came across this in github, but it was last updated in 2018: https://github.com/CWiesbaum/camunda-optimize-docker/blob/master/Dockerfile

Using the example above as a starting point, this is what I currently have, but I get errors that Optimize cannot find my locally running Elasticsearch. When I run the optimize-startup.bat locally (no docker), it starts up Optimize successfully. Also, i was able to successfully run the Optimize demo.

FROM openjdk:8-jre-slim
EXPOSE 8090 8091
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
ADD ./* /opt/camunda-optimize/
RUN groupadd camunda && useradd -ms /bin/bash -G camunda optimize && chown -R root:camunda /opt/camunda-optimize && chmod -R g+w /opt/camunda-optimize && chmod +x /opt/camunda-optimize/optimize-startup.sh
USER optimize:camunda
ENTRYPOINT [ "sh", "-c", "/opt/camunda-optimize/optimize-startup.sh" ]

Here is the error from Optimize when i start the container:

Starting Camunda Optimize 3.1.0...

17:47:00.394 [main] INFO  o.c.o.s.e.OptimizeElasticsearchClientFactory - Initializing Elasticsearch rest client...
17:47:00.829 [main] ERROR o.c.o.s.e.OptimizeElasticsearchClientFactory - Failed getting number of cluster nodes.
java.net.ConnectException: Connection refused
    at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:804)
    at org.elasticsearch.client.RestClient.performRequest(RestClient.java:225)
    at org.elasticsearch.client.RestClient.performRequest(RestClient.java:212)
    at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1433)
    at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1403)
    at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1373)
    at org.elasticsearch.client.ClusterClient.health(ClusterClient.java:118)
    at org.camunda.optimize.service.es.OptimizeElasticsearchClientFactory.getNumberOfClusterNodes(OptimizeElasticsearchClientFactory.java:68)
    at org.camunda.optimize.service.es.OptimizeElasticsearchClientFactory.waitForElasticsearch(OptimizeElasticsearchClientFactory.java:51)
    at org.camunda.optimize.service.es.OptimizeElasticsearchClientFactory.create(OptimizeElasticsearchClientFactory.java:34)
    at org.camunda.optimize.service.es.OptimizeElasticsearchClientConfiguration.optimizeElasticsearchClient(OptimizeElasticsearchClientConfiguration.java:29)
    at org.camunda.optimize.service.es.OptimizeElasticsearchClientConfiguration$$EnhancerBySpringCGLIB$$9fd26135.CGLIB$optimizeElasticsearchClient$0(<generated>)
    at org.camunda.optimize.service.es.OptimizeElasticsearchClientConfiguration$$EnhancerBySpringCGLIB$$9fd26135$$FastClassBySpringCGLIB$$37d89dfd.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
    at org.camunda.optimize.service.es.OptimizeElasticsearchClientConfiguration$$EnhancerBySpringCGLIB$$9fd26135.optimizeElasticsearchClient(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)

Here are my environment.yaml settings for elasticsearch:

es:
  connection:
# a list of Elasticsearch nodes Optimize can connect to. If you  have built
# an Elasticsearch cluster with several nodes it is recommended to define
# several connection points in case one node fails.
nodes:
# the address/hostname under which the Elasticsearch node is available.
- host: 'localhost'
  # A port number used by Elasticsearch to accept HTTP connections.
  httpPort: 9200
# HTTP forward proxy configuration
proxy:
  # whether an HTTP proxy should be used for requests to elasticsearch
  enabled: false
  # the host of the proxy to use
  host: null
  # the port of the proxy to use
  port: null
  # whether this proxy is using a secured connection
  sslEnabled: false

  # Elasticsearch security settings
  security:
# the basic auth (x-pack) username
username: null
# the basic auth (x-pack) password
password: null
# SSL/HTTPS secured connection settings
ssl:
  # path to a PEM encoded file containing the certificate (or certificate chain)
  # that will be presented to clients when they connect.
  certificate: null
  # A list of paths to PEM encoded CA certificate files that should be trusted, e.g. ['/path/to/ca.crt'].
  # Note: if you are using a public CA that is already trusted by the Java runtime,
  # you do not need to set the certificate_authorities.
  certificate_authorities: []
  # used to enable or disable TLS/SSL for the HTTP connection
  enabled: false

Hey @matty,

Really cool that you want to try out running Optimize in docker. Just one question out of curiosity: is there a reason why you don’t use the Camunda Optimize docker container? Then you don’t need to configure anything.

Best,
Johannes

1 Like

thanks! i made some progress using the camunda docker optimize container from the instructions you linked. but i get this error:

$ docker run --name optimize -e OPTIMIZE_CAMUNDABPM_REST_URL=http://my_ip:8080/engine-rest -e OPTIMIZE_ELASTICSEARCH_HOST=my_ip -e OPTIMIZE_ELASTICSEARCH_HTTP_PORT=9200 registry.camunda.cloud/optimize-                                                        ee/optimize:3.1.0
15:31:27.821 [main] INFO  o.c.o.s.e.OptimizeElasticsearchClientFactory - Initializing Elasticsearch rest client...
15:31:28.240 [main] INFO  o.c.o.s.e.OptimizeElasticsearchClientFactory - Elasticsearch client has successfully been started
15:31:28.613 [main] INFO  o.c.o.s.e.s.ElasticSearchSchemaManager - Updating Optimize schema...
15:31:29.051 [main] INFO  o.c.o.s.e.s.ElasticSearchSchemaManager - Creating or updating template with name optimize-event_v3
15:31:29.689 [main] INFO  o.c.o.s.e.s.ElasticSearchSchemaManager - Creating or updating template with name optimize-variable-update-instance_v2
15:31:29.905 [main] INFO  o.c.o.s.e.s.ElasticSearchSchemaManager - Finished updating Optimize schema.
15:31:30.960 [main] INFO  o.c.o.s.SyncedIdentityCacheService - Initializing user sync.
15:31:30.961 [main] INFO  o.c.o.s.SyncedIdentityCacheService - Scheduling User Sync
15:31:31.403 [ThreadPoolTaskScheduler-1] INFO  o.c.o.s.SyncedIdentityCacheService - Engine identity sync complete
15:31:31.844 [main] INFO  o.c.o.s.cleanup.CleanupScheduler - Initializing OptimizeCleanupScheduler
15:31:31.863 [main] INFO  o.c.o.s.cleanup.CleanupScheduler - Stopping cleanup scheduling
15:31:31.879 [main] INFO  o.c.o.s.u.c.e.IngestionConfiguration - No ingestion api secret was configured, generated a temporary token [hWBGdIwfPKLtXZFI].
15:31:33.846 [main] INFO  o.c.o.s.i.e.EngineImportScheduler - Start scheduling import from engine camunda-bpm.
15:31:34.077 [ThreadPoolTaskScheduler-1] INFO  o.c.o.s.i.e.s.VariableUpdateInstanceImportService - Refuse to add variable [invoiceDocument] from variable import adapter plugin. Variable has no type or type is not supported.

I’m glad you were able to make some progress. Regarding the error. Are you referring to this one?

15:31:34.077 [ThreadPoolTaskScheduler-1] INFO o.c.o.s.i.e.s.VariableUpdateInstanceImportService - Refuse to add variable [invoiceDocument] from variable import adapter plugin. Variable has no type or type is not supported.

As the log indicates, this is not an error but rather an information for you that there’s a variable that had been rejected because the type is not supported. Optimize imports only [primitive types|Process Variables | docs.camunda.org] by default. If you have a variable that is for example of type Json it will be rejected and Optimize will inform you about it. Does that make sense?

Best,
Johannes

Thanks, yes that makes sense.
I let the process run for about an hour and it moved past that statement, but stopped after that:

[ThreadPoolTaskScheduler-1] INFO  o.c.o.s.SyncedIdentityCacheService - Engine identity sync complete

I waited for about an hour, but Optimize wasn’t running on localhost:8090 when i checked. How long should the initial import take? I’m using a fresh Camunda BPM image that only has the default 2 processes (Invoice Receipt and Review Invoice).

When i try running Optimize without docker and run the optimize-startup.bat file, everything seems to work as expected. The import completes very quickly and i can access the Optimze UI via localhost:8090.

Also, does Optimize have a healthcheck endpoint?

Hey @matty,

but Optimize wasn’t running on localhost:8090 when i checked.

That’s weird. Usually, Optimize should be available after a couple of seconds.

How long should the initial import take?

With the default Camunda BPM distribution it should just take a couple of seconds. Even if the import is still ongoing the UI should be available at any time. So there seems something else wrong. Would do you get as a result if you access localhost:8090? Can you maybe add a screenshot?

Also, does Optimize have a healthcheck endpoint?

We want to add a dedicated health check endpoint with the next release but for now, you can just try to access http://localhost:8090/api/status.

Best,
Johannes

Thanks for the healthcheck.

When it is stuck on “Engine identity sync complete”, and i goto localhost:8090, i get a site cannot be reached:

here are the logs from above when we try to run the docker container. (when we run the optimize-startup.sh directly, it goes very quickly and we get Optimize running)

Like i mentioned above, when we run the optimize-startup.sh script directly, it works as expected so it seems the issue might be with our dockerfile. Are there any examples or obvious errors in the way we have our set up?

FROM openjdk:8-jre-slim
EXPOSE 8090 8091
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
ADD ./* /opt/camunda-optimize/
RUN groupadd camunda && useradd -ms /bin/bash -G camunda optimize && chown -R root:camunda /opt/camunda-optimize && chmod -R g+w /opt/camunda-optimize && chmod +x /opt/camunda-optimize/optimize-startup.sh
USER optimize:camunda
ENTRYPOINT [ "sh", "-c", "/opt/camunda-optimize/optimize-startup.sh" ]