Docker: OpenEMS backend not working out of the box

I´m trying to start the compose file for the OpenEMS backend. Startup of the container is working as expected. When going to http://localhost:80 … I´m getting a blank page with following error.

Does anybody have the same issue when starting the compose file?

Logs from the ui container

[migrations] started
[migrations] no migrations found
usermod: no changes
───────────────────────────────────────────                               
 _____ _____ _____ _____ _____ _____ _____ 
|     |  _  |   __|   | |   __|     |   __|
|  |  |   __|   __| | | |   __| | | |__   |
|_____|__|  |_____|_|___|_____|_|_|_|_____|      

    Based on images from linuxserver.io    
───────────────────────────────────────────
for further information visit:
https://openems.io/

───────────────────────────────────────
GID/UID:    911/911
───────────────────────────────────────
'/defaults/nginx/dhparams.pem' -> '/etc/nginx/dhparams.pem'
'/defaults/nginx/openems-nginx.conf' -> '/etc/nginx/openems-nginx.conf'
'/defaults/nginx/site-confs/openems.conf' -> '/etc/nginx/site-confs/openems.conf'
'/defaults/nginx/ssl.conf' -> '/etc/nginx/ssl.conf'
generating self-signed keys in /etc/nginx/keys, you can replace these with your own keys if required
..+..........+.........+++++++++++++++++++++++++++++++++++++++*...+.+.................+...............+......+.+...+++++++++++++++++++++++++++++++++++++++*....+....+..+....+...+..+....+............+.........+...+..+.+........+......+.+..+...+............+.......+...+...........+.......+..+...+...............+..........+..+.............+...............+........+.+...+..+.+..+......+....+.......................+.........+...+.......+......+..+.+..+.............+......+.....+....+.....+.+.....+.............+......+.....+.....................+....+......+........+...+.........+.+..+................+......+..................+........+...+............+.......+...........+.........+...+...+.+........+.+..............+...+...+.+......+.........+.......................+.+......+.........++++++
....+......+..+...+......+...+.+++++++++++++++++++++++++++++++++++++++*..+..+++++++++++++++++++++++++++++++++++++++*...+...+.......+...+..+....+..+............+.+..+....+......+...+...............+.........+...+........+...............+....+...+.........+.........+..+.............+..+.........+.+..+...............+.+.....+....+...+..+......+......+......+.............+..+............+...+...+.+.........+.....+......+...+.............+...+.....+.+.....+.+.....+..........+...+.....+.........+.+..+.........+...+......+....+...........+......+.+..+.+............+..+.+.....+....+..+...............+.+...+..+.......+............+........+.+......+...+.....+...+.......+............+.....+.+..+..........+...+............+..+....+............+..+.+..+............+...+...............+...+.......+..............+.+.....+...+.+......+..+.......+....................+....+......+...+........+.......+......+.....+.+........+.............+...+...........+...+...+....+.....+....+..+...+....+...+..+..........+........+...+.+...+............+.....+.+..............+.+.....+...+............+...+...................+..+.+...+..+....+.....+..........+...+.....+......+......+.........+............+.........+..........++++++
-----
[custom-init] No custom files found, skipping...

Maybe the UI_WEBSOCKET environment variable is not working as expected?

Greetings!

I still can´t figure out why it is not working.

Does anybody have a clue why it is not working? Could someone test this for me on their machine to check if the behavior is reproducable for others?

Edit:
I´m also not able to run the OpenEMS Edge docker-compose file. The same behaviour as the backend docker-compose file.

Sorry for asking, but what stops you from using the “native” Variant ?

I´m trying to build a OpemEMS Backend cluster with a reverse proxy (treafik) in front.

The big goal is to spin up a multiple OpenEMS Backend bundles (Backend, UI, Influx) which is then auto discovered by treafik. Treafik is then creating routes for the exposed ports of the containers.

The autodiscover function of treafik works the best with docker containers.

Has anybody run the OpenEMS Backend in a docker-compose bundle? If not I´m going to investigate a little deeper.

Greetings

I got it running with the help of this tutorial Dynamically set Angular Environment Variables in Docker.

I case somebody else wants to run the backend with docker and a configurable UI_WEBSOCKET here are the steps I did.

  1. Create a env.js file in directory /ui/src/assets/env.js with following content
(function(window) {
  window["env"] = window["env"] || {};

  // Environment variables
  window["env"]["websocket"] = "ws://localhost:8082";
})(this);
  1. Create a env.template.js file in directory /ui/src/assets/env.template.js with following content
(function(window) {
  window.env = window.env || {};

  // Environment variables
  window["env"]["websocket"] = "${UI_WEBSOCKET}";
})(this);
  1. Adjust file backend-docker.ts to following
// @ts-strict-ignore
import {Environment} from "src/environments";
import {theme} from "./theme";

window["env"] = window["env"] || {};

export const environment: Environment = {
    ...theme, ...{

        backend: 'OpenEMS Backend',
        url: window["env"]["websocket"] || "ws://" + location.hostname + ":8082",

        production: true,
        debugMode: false,
    },
};
  1. Uncomment Line 13 in following file index.html. This line should be uncommented
  <script src="assets/env.js" onerror="null"></script>
  1. Adjust the Dockerfile for the UI, add following command at the end of the file
CMD ["/bin/sh",  "-c",  "envsubst < /usr/share/nginx/html/assets/env.template.js > /usr/share/nginx/html/assets/env.js && exec nginx -g 'daemon off;'"]
  1. After that build your own docker image as descriped in the README.

I´m pretty sure this is not the “OpenEMS” way to do it … but it works for me :slight_smile:

Greetings!

1 Like