Trame app failing to load from Docker container due to `__trame_vtklocal/js/style.css`

Hi there,

First of all, thank you for all the great projects for handling and using meshes in all their various forms - they continue to be super helpful.

I am in the process of creating a “simple” mesh visualisation app using Trame’s localView.

I am able to successfully run it in ‘single user’ mode, by naively invoking server.start(), which lets me view the UI I created using trame’s widgets.

I am in the process of packaging the application up so that I can host it and have multiple users connect, each to their own session.

I am using the example provided here as inspiration.

My application boots up successfully with no errors in the apache logs nor the launcher logs.

My browser is stuck at the screen with a spinning circle and a Loading message.

Inspecting the network requests made by the browser, I can see every request succeeding as expected, all the way up to the 101 response that establishes the websocket connection.

The next request is for the __trame_vtklocal/js/style.css file - it returns a 200, but the response body is just the exact same content as the main index.html.

I looked into the apache2 config, and can see:

  <Directory /deploy/server/www>
      Options Indexes FollowSymLinks
      AllowOverride None
      Require all granted
      FallbackResource /index.html
  </Directory>

which led me to understand that the request was failing to find the resource, and was therefore falling back to the html file.

I looked inside the /deploy/server/www directory and could see subdirectories for the __trame_vtk and __trame_vuetify3 modules, containing their web assets (js, css, fonts).

I would have expected to also see a directory for __trame_vtklocal then - and I think its absence might explain my issues loading the stylesheets.

Is there something specific I should be doing in the setup and configuration of my Docker container to enable trame-localview to work?

Did you listed trame-vtklocal in your dependency for your app? Do you also have vtk>=9.4 in it?

While that part should actually work, I’m expecting a followup issue with the .wasm file missing, which may require an extra step in the initialize.sh.

I’ll try to look into it soonish, but if you want to speed things up, feel free to reach out to Kitware for some support.

A working example is available here

Hi Sebastien,

Many thanks for the super fast response! I am working on a case to get my employer to formally reach out to Kitware for some support, but in the meantime I appreciate your help in these forums.

I do indeed have trame-vtklocal listed as a dependency for my app. I worked around the issue by including

# symlink the __trame_vtklocal directory so that the server can serve the static files
RUN mkdir -p /deploy/server/www/__trame_vtklocal &&  mkdir -p /deploy/server/www/__trame_vtklocal \
    && ln -s /deploy/server/venv/lib/python3.10/site-packages/trame_vtklocal/module/serve/js /deploy/server/www/__trame_vtklocal \
    && ln -s /deploy/server/venv/lib/python3.10/site-packages/trame_vtklocal/module/serve/wasm /deploy/server/www/__trame_vtklocal

in my container which seems to work well enough. The .wasm files are loaded on the first user connection - I’ll try the initialize.sh addition to speed that up.

My current issue is that my deployment is into a kubernetes cluster where we have securityContext.runAsNonRoot: true. This means I am unable to deploy the application, as it appears to run as root.

Is there something simple I could change to avoid this?

I managed to avoid running as root by making my own entrypoint with:

  • service apache2 restart at the start
  • the full content of docker/scripts/run.sh

and got it working with the end of my Dockerfile being

    # Modify Apache config to use non-privileged port
RUN sed -i 's/Listen 80/Listen 8080/g' /etc/apache2/ports.conf && \
    sed -i 's/:80/:8080/g' /etc/apache2/sites-available/001-trame.conf

# Set permissions for logs
RUN mkdir -p /var/log/apache2 && \
    chown -R trame-user:trame-user /var/log/apache2

# Set permissions for run directory
RUN mkdir -p /var/run/apache2 && \
    chown -R trame-user:trame-user /var/run/apache2

# Set permissions for run directory
RUN mkdir -p /deploy/server/logs/apache/ && \
    chown -R trame-user:trame-user /deploy/server/logs/apache/


EXPOSE 8080

USER 1000
ENTRYPOINT [ "/deploy/my_entrypoint.sh" ]