Accessing Environment Variables from Theia front-end extension

I have a docker container running Theia with my custom extension. Is there a way for me to access the environment variables from my docker container inside of my extension? I tried process.env.<variable> and a couple other solutions and have had no luck.

@chrisfernandes102 thank you for the question, in the title you mentioned frontend extension, but I’d like to mention that in order to access environment variables this would need to be done in the backend (you can verify by looking at our sources for process.env and see that they are under the node (backend) folder.

As for reading the environment variables in a docker container, I believe it may be possible (thought I have never tried). The solution should also not be specific to the framework, you can try searching online on how to read environment variables in a nodejs application for instance:

@vince-fugnitto Thank you so much for the reply. I can access the variables from my docker file in the shell terminal. Do you know if there is a way to run a shell command within a frontend extension?

@chrisfernandes102 it should be possible, you can take a look at the following issue:

There were some discussions around the topic in the issue ( about using actual processes in-case the sendText example does not work.

@vince-fugnitto Awesome, so I was able to get that to work. Another issue I am seeing is that I for some reason cannot get the output of the command that was triggered which gets me in stuck in another direction. I guess my goal here is to get access to the backend application from my extension, so that I can access env variables, etc. Do you have any suggestions on if that is possible? I really appreciate your help here.

@chrisfernandes102 a custom theia-extension can have a frontend (browser) and backend (node) component. The idea would be to include a backend component to your existing extension which can access features such as environment variables. You can take a look at the main repository’s sources for examples, or you can take a look at the backend template as part of the extension generator (choosing “backend communication” as a template):

The main part of a backend component is specifying it (the location of your bindings) under your extension’s package.json with the theiaExtensions property:

"theiaExtensions": [
      "frontend": "lib/browser/example-frontend-module",
      "backend": "lib/node/example-backend-module"

For an example you can look at @theia/file-search which has a frontend and backend component: