How to launch my Avalonia .NET 8.0 application in release mode (production) on my device using docker-compose

Hi @ToradexAI

Here is my configuration:

torizon@verdin-imx8mp-15229850:~$ sudo tdx-info
Password:

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           5.15.148-6.6.1+git.23a8e831749d #1-TorizonCore SMP PREEMPT Thu Feb 29 20:25:21 UTC 2024
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.1/torizon/f5f0b9e40c1595ab904ce493a792a0b54e17f0dc3ce6832ddb889452bdd13704/0
Distro name:              NAME="TorizonCore"
Distro version:           VERSION_ID=6.6.1-build.14
Distro variant:           VARIANT="Docker"
Hostname:                 verdin-imx8mp-15229850
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Verdin iMX8M Plus WB on Verdin Development Board
Toradex version:          0058 V1.1B
Serial number:            15229850
Processor arch:           aarch64
------------------------------------------------------------

Here is my evaluation kit version:

[Hardware Configuration]
Verdin iMX8M Plus Evaluation Kit with Touchscreen
with:
SOM i.MX8M Plus Quad 4GB WB IT v1.1B
Dahlia Carrier Board v1.1D
Verdin DSI to LVDS rev 1.1A
Capacitive Touch Display 10.1" v1.0A

I use the Torizon IDE extension version v2.5.171 (pre-release) and VS Code 1.90.2 on my Windows 11 Business 23H2.

The problem I am facing is that I fail to launch my application in release mode.

Here are the logs of what I have on my target device, and what I am doing to start my application:

torizon@verdin-imx8mp-15229850:~$ ls -al
total 40
drwxr-xr-x 4 torizon torizon 4096 Jul  3 14:14 .
drwxr-xr-x 4 root    root    4096 Jan  1  1970 ..
-rw------- 1 torizon torizon 6310 Jun 26 14:36 .bash_history
-rwxr-xr-x 1 torizon torizon  286 Jan  1  1970 .bashrc
drwx------ 3 torizon torizon 4096 Jun 20 12:57 .config
drwx------ 3 torizon torizon 4096 Jul  3 14:14 .docker
-rw-r--r-- 1 torizon torizon   79 Jul  3 14:14 .env
-rwxr-xr-x 1 torizon torizon  241 Jan  1  1970 .profile
-rw-r--r-- 1 torizon torizon 1916 Jul  3 14:32 docker-compose.yml
torizon@verdin-imx8mp-15229850:~$ cat .env
LOCAL_REGISTRY=192.168.10.112
DOCKER_LOGIN=192.168.10.112
TAG=arm64
GPU=-imx8

torizon@verdin-imx8mp-15229850:~$ cat docker-compose.yml 
version: "3.9"
services:
  avalonia-gtk-mvvm-debug:
    build:
      context: .
      dockerfile: Dockerfile.debug
    image: ${LOCAL_REGISTRY}:5002/avalonia-gtk-mvvm:${TAG}
    ports:
      - 2223:2223
    volumes:
      - type: bind
        source: /tmp
        target: /tmp
      - type: bind
        source: /dev
        target: /dev
    device_cgroup_rules:
      # ... for tty0
      - "c 4:0 rmw"
      # ... for tty7
      - "c 4:7 rmw"
      # ... for /dev/input devices
      - "c 13:* rmw"
      - "c 199:* rmw"
      # ... for /dev/dri devices
      - "c 226:* rmw"
    depends_on: [
      weston
    ]

  avalonia-gtk-mvvm:
    build:
      context: .
      dockerfile: Dockerfile
    image: ${DOCKER_LOGIN}/avalonia-gtk-mvvm:${TAG}
    volumes:
      - type: bind
        source: /tmp
        target: /tmp
      - type: bind
        source: /dev
        target: /dev
    device_cgroup_rules:
      # ... for tty0
      - "c 4:0 rmw"
      # ... for tty7
      - "c 4:7 rmw"
      # ... for /dev/input devices
      - "c 13:* rmw"
      - "c 199:* rmw"
      # ... for /dev/dri devices
      - "c 226:* rmw"
    depends_on: [
      weston
    ]

  weston:
    image: commontorizon/weston${GPU}:next
    environment:
      - ACCEPT_FSL_EULA=1
    # Required to get udev events from host udevd via netlink
    network_mode: host
    volumes:
      - type: bind
        source: /tmp
        target: /tmp
      - type: bind
        source: /dev
        target: /dev
      - type: bind
        source: /run/udev
        target: /run/udev
    cap_add:
      - CAP_SYS_TTY_CONFIG
    # Add device access rights through cgroup...
    device_cgroup_rules:
      # ... for tty0
      - "c 4:0 rmw"
      # ... for tty1
      - "c 4:1 rmw"
      # ... for tty7
      - "c 4:7 rmw"
      # ... for /dev/input devices
      - "c 13:* rmw"
      - "c 199:* rmw"
      # ... for /dev/dri devices
      - "c 226:* rmw"
torizon@verdin-imx8mp-15229850:~$ docker image ls
REPOSITORY                              TAG       IMAGE ID       CREATED          SIZE
192.168.10.112:5002/avalonia-gtk-mvvm   arm64     eac4b55e159d   53 minutes ago   811MB
commontorizon/weston-imx8               next      83f43412224c   3 weeks ago      511MB
nodered/node-red                        3.1.3     12234ad916b0   5 months ago     564MB
torizon@verdin-imx8mp-15229850:~$ docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
torizon@verdin-imx8mp-15229850:~$ docker-compose up -d
[+] Running 1/1
 ! avalonia-gtk-mvvm Warning                                                                                      15.0s 
[+] Building 0.1s (1/2)                                                                                  docker:default
 => [avalonia-gtk-mvvm internal] load build definition from Dockerfile                                             0.0s
 => => transferring dockerfile: 2B                                                                                 0.0s
failed to solve: failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount2310827459/Dockerfile: no such file or directory

When I try to start my application issuing the docker-compose up -d, it fails with the message:

failed to solve: failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount2310827459/Dockerfile: no such file or directory

But, when I click on the task , I have the following logs in the terminal of VS Code, and the application is running correctly on my board and the display of the GUI on my touchscreen is correct aslo.

=============>             ]  22.94MB/30.81MB
 849fdfa11c07 Extracting [======================================>            ]  23.92MB/30.81MB
 849fdfa11c07 Extracting [========================================>          ]   24.9MB/30.81MB
 849fdfa11c07 Extracting [==========================================>        ]  25.89MB/30.81MB
 849fdfa11c07 Extracting [===========================================>       ]  26.87MB/30.81MB
 849fdfa11c07 Extracting [=============================================>     ]  27.85MB/30.81MB
 849fdfa11c07 Extracting [==============================================>    ]  28.84MB/30.81MB
 849fdfa11c07 Extracting [================================================>  ]  29.82MB/30.81MB
 849fdfa11c07 Extracting [=================================================> ]   30.8MB/30.81MB
 849fdfa11c07 Extracting [==================================================>]  30.81MB/30.81MB
 849fdfa11c07 Pull complete 
 11d7b786b094 Extracting [==================================================>]     347B/347B
 11d7b786b094 Extracting [==================================================>]     347B/347B
 11d7b786b094 Pull complete 
 b4e35910b6a0 Extracting [=>                                                 ]  32.77kB/1.011MB
 b4e35910b6a0 Extracting [===>                                               ]  65.54kB/1.011MB
 b4e35910b6a0 Extracting [=========================>                         ]  524.3kB/1.011MB
 b4e35910b6a0 Extracting [===========================================>       ]  884.7kB/1.011MB
 b4e35910b6a0 Extracting [==================================================>]  1.011MB/1.011MB
 b4e35910b6a0 Extracting [==================================================>]  1.011MB/1.011MB
 b4e35910b6a0 Pull complete 
 0502f956be65 Extracting [>                                                  ]  524.3kB/50.2MB
 0502f956be65 Extracting [=>                                                 ]  1.573MB/50.2MB
 0502f956be65 Extracting [==>                                                ]  2.621MB/50.2MB
 0502f956be65 Extracting [===>                                               ]  3.146MB/50.2MB
 0502f956be65 Extracting [====>                                              ]  4.194MB/50.2MB
 0502f956be65 Extracting [=====>                                             ]  5.243MB/50.2MB
 0502f956be65 Extracting [======>                                            ]  6.291MB/50.2MB
 0502f956be65 Extracting [=======>                                           ]   7.34MB/50.2MB
 0502f956be65 Extracting [========>                                          ]  8.389MB/50.2MB
 0502f956be65 Extracting [=========>                                         ]  9.437MB/50.2MB
 0502f956be65 Extracting [==========>                                        ]  10.49MB/50.2MB
 0502f956be65 Extracting [===========>                                       ]  11.53MB/50.2MB
 0502f956be65 Extracting [============>                                      ]  12.58MB/50.2MB
 0502f956be65 Extracting [=============>                                     ]  13.63MB/50.2MB
 0502f956be65 Extracting [==============>                                    ]  14.68MB/50.2MB
 0502f956be65 Extracting [===============>                                   ]  15.73MB/50.2MB
 0502f956be65 Extracting [================>                                  ]  16.78MB/50.2MB
 0502f956be65 Extracting [=================>                                 ]  17.83MB/50.2MB
 0502f956be65 Extracting [==================>                                ]  18.87MB/50.2MB
 0502f956be65 Extracting [===================>                               ]  19.92MB/50.2MB
 0502f956be65 Extracting [====================>                              ]  20.97MB/50.2MB
 0502f956be65 Extracting [=====================>                             ]  22.02MB/50.2MB
 0502f956be65 Extracting [======================>                            ]  23.07MB/50.2MB
 0502f956be65 Extracting [========================>                          ]  24.12MB/50.2MB
 0502f956be65 Extracting [=========================>                         ]  25.17MB/50.2MB
 0502f956be65 Extracting [==========================>                        ]  26.21MB/50.2MB
 0502f956be65 Extracting [===========================>                       ]  27.26MB/50.2MB
 0502f956be65 Extracting [============================>                      ]  28.31MB/50.2MB
 0502f956be65 Extracting [=============================>                     ]  29.36MB/50.2MB
 0502f956be65 Extracting [==============================>                    ]  30.41MB/50.2MB
 0502f956be65 Extracting [===============================>                   ]  31.46MB/50.2MB
 0502f956be65 Extracting [================================>                  ]  32.51MB/50.2MB
 0502f956be65 Extracting [=================================>                 ]  33.55MB/50.2MB
 0502f956be65 Extracting [==================================>                ]   34.6MB/50.2MB
 0502f956be65 Extracting [===================================>               ]  35.65MB/50.2MB
 0502f956be65 Extracting [====================================>              ]   36.7MB/50.2MB
 0502f956be65 Extracting [=====================================>             ]  37.75MB/50.2MB
 0502f956be65 Extracting [======================================>            ]   38.8MB/50.2MB
 0502f956be65 Extracting [=======================================>           ]  39.32MB/50.2MB
 0502f956be65 Extracting [=======================================>           ]  39.85MB/50.2MB
 0502f956be65 Extracting [========================================>          ]  40.89MB/50.2MB
 0502f956be65 Extracting [=========================================>         ]  41.94MB/50.2MB
 0502f956be65 Extracting [==========================================>        ]  42.47MB/50.2MB
 0502f956be65 Extracting [==========================================>        ]  42.99MB/50.2MB
 0502f956be65 Extracting [===========================================>       ]  44.04MB/50.2MB
 0502f956be65 Extracting [============================================>      ]  45.09MB/50.2MB
 0502f956be65 Extracting [=============================================>     ]  45.61MB/50.2MB
 0502f956be65 Extracting [=============================================>     ]  46.14MB/50.2MB
 0502f956be65 Extracting [==============================================>    ]  46.66MB/50.2MB
 0502f956be65 Extracting [==============================================>    ]  47.19MB/50.2MB
 0502f956be65 Extracting [================================================>  ]  48.23MB/50.2MB
 0502f956be65 Extracting [================================================>  ]  48.76MB/50.2MB
 0502f956be65 Extracting [=================================================> ]  49.28MB/50.2MB
 0502f956be65 Extracting [=================================================> ]  49.81MB/50.2MB
 0502f956be65 Extracting [==================================================>]   50.2MB/50.2MB
 0502f956be65 Pull complete 
 96d2f4b00c37 Extracting [==================================================>]     268B/268B
 96d2f4b00c37 Extracting [==================================================>]     268B/268B
 96d2f4b00c37 Pull complete 
 80571161145d Extracting [>                                                  ]  131.1kB/10.46MB
 80571161145d Extracting [=====>                                             ]  1.049MB/10.46MB
 80571161145d Extracting [==========>                                        ]  2.097MB/10.46MB
 80571161145d Extracting [==============>                                    ]  3.015MB/10.46MB
 80571161145d Extracting [==================>                                ]  3.801MB/10.46MB
 80571161145d Extracting [======================>                            ]  4.719MB/10.46MB
 80571161145d Extracting [==========================>                        ]  5.636MB/10.46MB
 80571161145d Extracting [===============================>                   ]  6.554MB/10.46MB
 80571161145d Extracting [===================================>               ]  7.471MB/10.46MB
 80571161145d Extracting [========================================>          ]  8.389MB/10.46MB
 80571161145d Extracting [=============================================>     ]  9.437MB/10.46MB
 80571161145d Extracting [=================================================> ]  10.35MB/10.46MB
 80571161145d Extracting [==================================================>]  10.46MB/10.46MB
 80571161145d Extracting [==================================================>]  10.46MB/10.46MB
 80571161145d Pull complete 
 4f4fb700ef54 Extracting [==================================================>]      32B/32B
 4f4fb700ef54 Extracting [==================================================>]      32B/32B
 4f4fb700ef54 Pull complete 
 avalonia-gtk-mvvm Pulled 
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: DOCKER_HOST=192.168.10.111:2375 DOCKER_LOGIN=192.168.10.112:5002 TAG=arm64 GPU=-imx8 docker compose -p torizon up avalonia-gtk-mvvm 

WARN[0000] The "LOCAL_REGISTRY" variable is not set. Defaulting to a blank string. 
WARN[0000] /home/torizon/dev/AvaloniaGTKMVVM/docker-compose.yml: `version` is obsolete 
[+] Running 3/2
 ✔ Network torizon_default                Created                                               0.1s 
 ✔ Container torizon-weston-1             Created                                               4.2s 
 ✔ Container torizon-avalonia-gtk-mvvm-1  Created                                               0.1s 
Attaching to avalonia-gtk-mvvm-1
avalonia-gtk-mvvm-1  | EGL: Warning: No default display support on wayland
avalonia-gtk-mvvm-1  | Hello Torizon!
torizon@verdin-imx8mp-15229850:~$ docker image ls
REPOSITORY                              TAG       IMAGE ID       CREATED             SIZE
192.168.10.112:5002/avalonia-gtk-mvvm   <none>    eac4b55e159d   About an hour ago   811MB
192.168.10.112:5002/avalonia-gtk-mvvm   arm64     08f84ae4f925   7 hours ago         588MB
commontorizon/weston-imx8               next      83f43412224c   3 weeks ago         511MB
nodered/node-red                        3.1.3     12234ad916b0   5 months ago        564MB
torizon@verdin-imx8mp-15229850:~$ docker ps -a
CONTAINER ID   IMAGE                                         COMMAND               CREATED         STATUS                   PORTS     NAMES
67a444b1f983   192.168.10.112:5002/avalonia-gtk-mvvm:arm64   "./AvaloniaGTKMVVM"   2 minutes ago   Up 2 minutes                       torizon-avalonia-gtk-mvvm-1
dc42507e7b1e   commontorizon/weston-imx8:next                "/usr/bin/entry.sh"   2 minutes ago   Up 2 minutes (healthy)             torizon-weston-1
torizon@verdin-imx8mp-15229850:~$ 

So, I wonder what is incorrect in my workflow for launching my application using the command docker-compose up -d, since the images are already on the target device and the docker-compose.yml and the .env files are in same the directory where I issue the command docker-compose up -d command.

Could you please help me on this topic ?

Thank you.

Sincerely,
François.

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello François,

The issue you’re encountering with docker-compose up -d failing due to Docker not finding the Dockerfile appears to be related to the build context specified in your docker-compose.yml file. When you use Docker Compose to build an image, it expects to find a Dockerfile in the context path specified. However, in a production or release scenario, you typically don’t build the image on the target device but rather pull a pre-built image from a registry.

Given the logs and the successful deployment when triggered from VS Code, it seems the image is correctly built and available on your device. The problem arises because Docker Compose is instructed to build the image (which it shouldn’t in this case, as the image already exists on the device), and it cannot find the Dockerfile because it’s likely not present on your target device.

To resolve this issue, you should modify your docker-compose.yml to remove the build section for the avalonia-gtk-mvvm service if you’re deploying a pre-built image. Your docker-compose.yml should only contain the image directive for running the container, assuming the image is already built and available on your device or your local registry. Here’s how you can adjust the relevant section:

services:
  avalonia-gtk-mvvm:
    image: ${DOCKER_LOGIN}/avalonia-gtk-mvvm:${TAG}
    volumes:
      - type: bind
        source: /tmp
        target: /tmp
      - type: bind
        source: /dev
        target: /dev
    device_cgroup_rules:
      # ... for tty0
      - "c 4:0 rmw"
      # ... for tty7
      - "c 4:7 rmw"
      # ... for /dev/input devices
      - "c 13:* rmw"
      - "c 199:* rmw"
      # ... for /dev/dri devices
      - "c 226:* rmw"
    depends_on:
      - weston

Ensure your .env file has the correct DOCKER_LOGIN and TAG values set, and the image name matches the one you’ve pushed to your registry.

After making these changes, run docker-compose up -d again. This should start your application without attempting to build it, thus avoiding the error related to the missing Dockerfile.

Best regards,
Toradex AI Assistant

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

How to use Gstreamer on Torizon OS | Toradex Developer Center.

Hi @ToradexAI

I have tried your advise, but I have still a failure. The message is different, but it still fails.

torizon@verdin-imx8mp-15229850:~$ cat docker-compose.yml
version: "3.9"
services:
  avalonia-gtk-mvvm:
    image: ${DOCKER_LOGIN}/avalonia-gtk-mvvm:${TAG}
    volumes:
      - type: bind
        source: /tmp
        target: /tmp
      - type: bind
        source: /dev
        target: /dev
    device_cgroup_rules:
      # ... for tty0
      - "c 4:0 rmw"
      # ... for tty7
      - "c 4:7 rmw"
      # ... for /dev/input devices
      - "c 13:* rmw"
      - "c 199:* rmw"
      # ... for /dev/dri devices
      - "c 226:* rmw"
    depends_on: [
      weston
    ]

  weston:
    image: commontorizon/weston${GPU}:next
    environment:
      - ACCEPT_FSL_EULA=1
    # Required to get udev events from host udevd via netlink
    network_mode: host
    volumes:
      - type: bind
        source: /tmp
        target: /tmp
      - type: bind
        source: /dev
        target: /dev
      - type: bind
        source: /run/udev
        target: /run/udev
    cap_add:
      - CAP_SYS_TTY_CONFIG
    # Add device access rights through cgroup...
    device_cgroup_rules:
      # ... for tty0
      - "c 4:0 rmw"
      # ... for tty1
      - "c 4:1 rmw"
      # ... for tty7
      - "c 4:7 rmw"
      # ... for /dev/input devices
      - "c 13:* rmw"
      - "c 199:* rmw"
      # ... for /dev/dri devices
      - "c 226:* rmw"

torizon@verdin-imx8mp-15229850:~$ cat .env
LOCAL_REGISTRY=192.168.10.112
DOCKER_LOGIN=192.168.10.112
TAG=arm64
GPU=-imx8

torizon@verdin-imx8mp-15229850:~$ docker-compose up -d
[+] Running 1/1
 ✘ avalonia-gtk-mvvm Error                                                                                                                                                                                                                                                                                             15.0s
Error response from daemon: Get "https://192.168.10.112/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

Do you have a suggestion ?

Thank you.

Sincerely,
François.

Hi @flepron,

Thanks for providing all the necessary information!

I understand that you are trying to launch your application in release mode. However, I think you have probably missed a couple of steps.
Did you follow the steps on this page: Build, Test and Push Applications for Production | Toradex Developer Center

Basically, you need to create your production image first by running the create-production-image task which will create the docker-compose.prod.yml file. This task will also ask you for your docker hub credentials so that it can push the production ready docker image (built based on Dockerfile) into your dockerhub registry. From your error logs, it looks like you haven’t either run this task or have got something wrong while entering your credentials.

Next step is to build and push your application (which is based on the docker-compose.prod.yml file) into your Torizon Cloud account. For this, you have to run the tcb-platform-publish task. If that is successful, you will see your pushed package on your cloud account. Then you can deploy an application update to your Toradex hardware from the cloud. Here is how you will initiate an application update: First Steps with Torizon Remote Updates | Toradex Developer Center

Once that is done the docker-compose.yml file for production ready application will be available in /var/sota/storage/docker-compose directory. The docker-compose service present on Torizon OS will bring up this docker-compose file automatically on every boot up. You should see the containers in the docker ps command as something like this:


torizon@verdin-imx8mp-15035975:$ docker ps
CONTAINER ID   IMAGE                          COMMAND               CREATED          STATUS          PORTS     NAMES
2fef7c476f73   rudhi/avaloniagtkcontainer   "./AvaloniaGTKapp"    20 minutes ago   Up 20 minutes             torizon-avaloniagtkcontainer-1
7299869031ca   commontorizon/weston-imx8      "/usr/bin/entry.sh"   20 minutes ago   Up 20 minutes             torizon-weston-1

Note that the avalonia gtk container is based on the image rudhi/avaloniagtkcontainer hosted on my dockerhub registry, not from the local private registry.

1 Like

Dear @rudhi.tx

Thank you for these explanations.

You are right. I did not think that I have to do all these steps to test locally the production version of my application which must be encapsulated into an image pushed on Torizon Cloud.

Can we keep this topic opened, because today I am working on my Avalonia GTK MVVM Application, but I have other questions on this topic, but I have not the time today for describing my needs and remaining issues.

Thank you very much. Things are moving forward, and progress is being made.

Sincerely,
François LEPRON

1 Like

@flepron

Thanks for the update! Sure, I will keep this topic open.

1 Like

Hi @rudhi.tx and @matheus.tx

I have made “the translation”, of the job did by Mamma Mia Dev (https://www.youtube.com/@MammaMiaDev/featured) GitHub - MammaMiaDev/avaloniaui-the-series: Codebase for the Avalonia series on YouTube. from a Visual Studio Avalonia Solution (Windows Desktop + Android) to VS Code Torizon (Toradex’s Verdin i.MX 8M Plus) Avalonia GTK MVVM template and this works quite well with my Dahlia board with a Verdin i.MX 8M Plus and a 10.1" touchscreen.

Here is my GitHub repository (GitHub - FLepron-PoolCop/AvaloniaUITheSeriesGTKMVVM) of the “translation” I did, so that you can tell me if you have time to check if there are improvements which can be brought.

This is quite well responsive. This could be better if I am sure that the Hardware Acceleration is used. I have been told that using glxinfo from the package mesa-utils I could see if this option is enabled, but I have not been able to check it.

Let me know if I can achieve better performances with the DRM FB template.

Thank you for your feedbacks.

Sincerely,
François.