Deploying the server¶
Audience: IT administrators and platform teams · ~10 min read · Prerequisites: Security and privacy, Docker, and Docker Compose 2.24 or later for the proxy overlay
What it is¶
The struktJS desktop app is the main way to use the product. For a company that prefers to run it centrally, the same IDE also runs as a server: the Eclipse Theia browser IDE in a container, opened from a normal browser. This page covers the image, how to run it on one machine, and how to put it behind your own login.
The repository provides:
| File | What it is |
|---|---|
Dockerfile |
A multi-stage build of the browser IDE for Linux. |
deploy/server/docker-compose.yml |
One host, the IDE published on 127.0.0.1 only. |
deploy/server/docker-compose.proxy.yml |
An overlay that adds an authenticating reverse proxy and removes the published port. |
deploy/server/nginx.conf |
The proxy configuration with the settings that must not be changed. |
tests/test-theia-container-smoke.spec.js |
A browser check that proves a running container works. |
Before you start: what this is and is not¶
One container is one Theia process, with no user isolation
Everyone whose browser connects to a container shares its filesystem and its Terminal, and the Terminal is a shell running as the container's user. There is no per-user sign-in, workspace, or permission inside the IDE.
Run one container per person, or one per team that already trusts each other. Put it on an internal network behind your own authentication. Do not expose it to the internet.
What you get from the server mode: the same IDE as the desktop app, installed once, with nothing to install on the user's machine and with the models and languages kept on a server volume. What you do not get: single sign-on, roles, an audit log, or isolation between users. Those belong to the proxy and the platform you run it on, and are not features of the IDE.
Build the image¶
Build from a clean checkout or a source export, so the image contains exactly what is committed:
docker build -t struktjs-server --build-arg STRUKTJS_BUILD_COMMIT=$(git rev-parse --short HEAD) .
- The image is about 1.7 GB. The build took about 4 minutes on a 14-core Apple-silicon machine with a fast connection; expect more on a small build agent. It installs the dependencies, runs the
same build as the continuous-integration job for the browser app, downloads the bundled VS Code extensions from open-vsx.org and
checks them against
theia-app/theia-plugins.sha256. It then compiles the native modules for the image's own operating system. STRUKTJS_BUILD_COMMITnames the commit in the status bar; without it the image saysunknown(a source export has no.git).- On a network that cannot reach open-vsx.org add
--build-arg DOWNLOAD_PLUGINS=0. The image then has no bundled Python, JSON or TypeScript language features; the struktJS editor itself is unaffected. - The architecture is the build machine's. A build on an Apple-silicon Mac produces
linux/arm64; most servers arelinux/amd64. Build for the server's architecture withdocker buildx build --platform linux/amd64 ...or build on a machine of that architecture. Onlylinux/arm64has been tested here. - Without internet access on the target host, build where there is access and move the image:
docker save struktjs-server | gzip > struktjs-server.tar.gz, thendocker load < struktjs-server.tar.gzon the target.
The build fails on purpose, rather than producing a broken image, if the backend bundle does not load the struktJS backend module (the failure that otherwise leaves a bare Welcome screen with every asset a 404).
Run it on one machine¶
docker run -d --name struktjs --init -p 127.0.0.1:3000:3000 -v struktjs-work:/workspace struktjs-server
docker logs struktjs 2>&1 | grep "Launch token"
The log line looks like this:
[struktjs] Launch token required. Open: http://127.0.0.1:3000/?strukts_token=vJsmi6fBUlIaGcfBWamF6PpNM0Ejuu3P
Open that URL in your browser. The IDE answers 401 to anything without the token, then sets a cookie and redirects. The line
shows the container's own port; if you published a different one, keep the ?strukts_token=... part and change the address
(http://127.0.0.1:8000/?strukts_token=...). The token is new on every start.
The same, with the volumes and limits recommended below:
docker compose -f deploy/server/docker-compose.yml up --build -d
| Variable | Default | Meaning |
|---|---|---|
STRUKTJS_PORT |
3000 |
Port published on 127.0.0.1. |
STRUKTJS_VERSION |
latest |
Tag given to the built image. |
STRUKTJS_MEM_LIMIT |
4g |
Memory limit of the container. |
STRUKTJS_BUILD_COMMIT |
unknown |
Commit shown in the status bar. |
Put it behind your login¶
For people other than the one who started it, put an authenticating reverse proxy in front and stop publishing the IDE's port:
htpasswd -c deploy/server/htpasswd alice # example only
export STRUKTJS_PUBLIC_HOST=ide.example.com # the name users type in the browser
docker compose -f deploy/server/docker-compose.yml -f deploy/server/docker-compose.proxy.yml up --build -d
The overlay publishes only the proxy (default 127.0.0.1:8080; set STRUKTJS_PROXY_BIND and STRUKTJS_PROXY_PORT to change it).
It switches the launch token off, because your proxy is now the login and a token that only the container log shows cannot work for
other people. It sets STRUKTJS_ALLOWED_HOSTS to your host name. The example proxy uses basic authentication so that it works
out of the box; replace that with your single sign-on gateway, oauth2-proxy, or your ingress controller's authentication, and add
TLS.
Three proxy settings are required, and the example configuration has all of them:
- Pass the original
Hostheader (proxy_set_header Host $host;). The IDE's API refuses a request whoseHostis not a loopback name or listed inSTRUKTJS_ALLOWED_HOSTS, and one whoseOrigindoes not match itsHost. A proxy that rewritesHostto the container name (the default in many setups) makes every API call fail with403. - Pass the WebSocket upgrade headers. Without them the page loads and then cannot talk to its backend.
- No buffering, long timeouts. The IDE keeps one WebSocket open for the whole session.
This was verified against the example configuration: with Host passed through the API answers 200; with Host rewritten
it answers 403; a Host that is not listed answers 403; and a request without a login is stopped by the proxy with 401.
Data, updates and backups¶
| Mount | Holds |
|---|---|
/workspace |
The folder the IDE opens: models, languages, git repositories. Back this up. |
/home/node/.theia |
Settings, installed extensions, layout. |
/home/node/.struktjs |
The sample workspace copy and the language and plugin store. |
The container runs as the unprivileged user node (uid 1000), never as root. With a bind mount instead of a named volume, make
the folder writable for that user (chown -R 1000:1000 /srv/struktjs/workspace).
To update, build or load the new image and recreate the container; the volumes keep everything. The IDE does not update itself.
Health and logs¶
The image has a health check that asks the server for its front page and accepts any answer below 500. With the launch token on
that answer is 401, which still proves the process is serving HTTP. It does not prove that the IDE works. To check that, run
the browser test against the container; it opens the workbench, loads a sample into the projectional editor and runs a command in
the terminal:
STRUKTJS_CONTAINER_URL=http://127.0.0.1:3000 STRUKTJS_CONTAINER_TOKEN=<token from the log> \
npx playwright test --config=playwright.theia.config.js tests/test-theia-container-smoke.spec.js
(Add STRUKTJS_CONTAINER_AUTH=user:password behind a proxy that asks for basic authentication, and
STRUKTJS_CONTAINER_NAME=<container> to also read back what the terminal wrote.)
Logs go to standard output: docker logs. At start-up the log shows three ERROR ... plugin localization bundles ... l10n lines
for the bundled Python extensions. They only mean that those extensions' own interface strings are not translated; nothing else is
affected.
Hardening checklist¶
- [ ] One container per person or trusted team; never the open internet.
- [ ] An authenticating proxy with TLS in front; the IDE's port not published.
- [ ] The compose file's
no-new-privileges,cap_drop: ALL, process and memory limits left in place. - [ ] Network egress limited to what the people using it need. The IDE contacts nothing unless a feature is used (see Security and privacy); the Extensions view, if used, talks to open-vsx.org.
- [ ] Back up
/workspace; treat the container as replaceable. - [ ] Language files and plugins that people open run code on the server. The IDE asks before running one; give that choice only to people you trust with a shell on that container.
Troubleshooting¶
| Symptom | Cause and fix |
|---|---|
401 and "requires its launch token" |
The token is on (default). Open the URL from docker logs, or put a login proxy in front and set STRUKTJS_REQUIRE_LAUNCH_TOKEN=0. |
| Page loads, then the IDE is stuck or disconnects | The proxy does not pass the WebSocket upgrade headers. |
Everything works until you open or save, then 403 |
The proxy rewrites Host, or STRUKTJS_ALLOWED_HOSTS does not list the name users type. |
Welcome screen with no struktJS content, asset 404s |
The backend bundle lacks the struktJS module. A correct image build refuses to finish in that state; rebuild. |
The IDE is blank when embedded in a portal page (frame-ancestors in the browser console) |
The IDE refuses to be framed by other origins. Set STRUKTJS_FRAME_ANCESTORS to the portal origin, for example 'self' https://portal.example.com. |
PayloadTooLargeError: request entity too large in the backend log when opening or saving a very large model |
The file bridge accepts bodies up to 256 MB by default. Raise it with STRUKTJS_MAX_BODY (for example 512mb). |
permission denied on the workspace |
A bind-mounted folder is not writable for uid 1000. |