Run an Avalonia MVVM on Linux amd64 (Ubuntu)

Hi Toradex,

Is it possible, using the wayland compositor weston to run an avalonia application in a linux amd64 environment (Ubuntu) as Docker containers?

Also making the avalonia application as autorun by customizing the weston through the weston.ini configuration, using the [autolaunch] attribut.

Any help?

Ahmed49

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hi Ahmed49,

Yes, it is possible to run an Avalonia application in a Linux amd64 environment (Ubuntu) using the Wayland compositor Weston within Docker containers. Additionally, you can configure the application to autorun by customizing the weston.ini file.

Here are the steps to achieve this:

  1. Create a Dockerfile for your Avalonia application:

    • Ensure your Dockerfile sets up the necessary environment for running Avalonia on Linux.
    • Install dependencies such as .NET runtime and any other required libraries.
  2. Create a Dockerfile for Weston:

    • Use a base image that includes Weston, such as torizon/weston.
    • Ensure the Dockerfile sets up Weston to run as a Wayland compositor.
  3. Customize the weston.ini file:

    • Create a weston.ini file with the necessary configuration.
    • Use the [autolaunch] section to specify your Avalonia application.

Here is an example of how you might set up the weston.ini file:

[core]
backend=drm-backend.so

[autolaunch]
path=/path/to/your/avalonia/application
  1. Run the Docker containers:
    • Start the Weston container with the customized weston.ini file.
    • Ensure the Avalonia application container is set to communicate with the Weston container.

Here is an example of how you might run the containers using Docker Compose:

version: '3.8'
services:
  weston:
    image: torizon/weston
    volumes:
      - ./weston.ini:/etc/xdg/weston/weston.ini
    devices:
      - /dev/dri:/dev/dri
    environment:
      - ACCEPT_FSL_EULA=1
    command: weston --tty=1 --backend=drm-backend.so

  avalonia-app:
    image: your-avalonia-app-image
    environment:
      - WAYLAND_DISPLAY=wayland-0
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix
    depends_on:
      - weston
  1. Ensure the Avalonia application is set to autorun:
    • In the weston.ini file, the [autolaunch] section should point to the executable of your Avalonia application.

By following these steps, you should be able to run your Avalonia application in a Docker container with Weston as the Wayland compositor and have it autorun using the weston.ini configuration.

If you need further assistance or specific examples, please let me know!

Best regards,
[Your Name]

Please, also check if these links can help you solve your problem:

Avalonia: [OpenGL] Unable to initialize GLX-based rendering.

Hi @Ahmed49 !

Yes it is possible, but AFAIK, this is not something that we have out-of-the-box for you to use.

If you are using Torizon IDE to develop your project (which seems like you are - Run-container-torizon-release-arm64 failed) you would need to customize the project configuration to launch it on your development PC inside a container.

(You can see I am inferring that you want to do this on a Linux AMD64 to be able to execute it on your development PC. Please let me know if my supposition is wrong :slight_smile: )

What we have already available that you could use is the Local (native) build/launch configuration on the Torizon IDE template that will be executed directly on your development PC without the use of containers. Wouldn’t this be helpful for you?

If you could share more details about your use case, maybe we could recommend something else :slight_smile:

Seems like it is possible, but I have never tried it. Seems to be quite straightforward to use:

https://man.archlinux.org/man/weston.ini.5#AUTOLAUNCH_SECTION

Although this documentation is for the version 14 of Weston, seems like the version of Weston that we have in our containers for Torizon OS 6 (Weston version 10) also has it (https://gitlab.freedesktop.org/wayland/weston/-/blob/10.0/man/weston.ini.man?ref_type=heads#L686).

Best regards,