Deploy VS Code Application Permanently

Hello Team Toradex,
when I am try to Deploy VS code application Permanently On Verdin imx8mp device i am using the below commands
1.docker build -t my-qt-app .
2.docker tag my-qt-app my-dockerhub-user/my-qt-app:v1.0
docker push my-dockerhub-user/my-qt-app:v1.0
3.docker pull my-dockerhub-user/my-qt-app:v1.0
4.docker run -d --name my-qt-app --restart=always -v /dev:/dev --privileged my-dockerhub-user/my-qt-app:v1.0
5.sudo systemctl enable my-qt-app.service
sudo systemctl start my-qt-app.service
But I am facing error while applying the all above command. the error is mentioned below

+] Building 0.2s (3/3) FINISHED                                                                                                               docker:default
 => [internal] load build definition from Dockerfile                                                                                                     0.0s
 => => transferring dockerfile: 32B                                                                                                                      0.0s
 => [internal] load .dockerignore                                                                                                                        0.0s
 => => transferring context: 34B                                                                                                                         0.0s
 => ERROR [internal] load metadata for localhost:5002/qt6-wayland-imx8:3.3.1                                                                             0.0s
------
 > [internal] load metadata for localhost:5002/qt6-wayland-imx8:3.3.1:
------
ERROR: failed to solve: failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to do request: Head "http://localhost:5002/v2/qt6-wayland-imx8/manifests/3.3.1": dial tcp [::1]:5002: connect: connection refused

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

Did you like my answer?

:+1: :-1:


It looks like you’re encountering an issue with the Docker build process, specifically when trying to load metadata for the base image localhost:5002/qt6-wayland-imx8:3.3.1. The error message indicates that Docker is unable to connect to the local registry at localhost:5002.

Here are a few steps to troubleshoot and resolve this issue:

  1. Check Local Registry:

    • Ensure that you have a Docker registry running on localhost:5002. You can check this by running:
      docker ps
      
    • If the registry is not running, you can start it with:
      docker run -d -p 5002:5000 --name registry registry:2
      
  2. Verify Image Availability:

    • Make sure that the image qt6-wayland-imx8:3.3.1 is available in your local registry. You can list the images in your local registry by:
      curl http://localhost:5002/v2/_catalog
      
  3. Correct Image Reference:

    • If the image is not in your local registry, you might need to pull it from a remote registry or build it locally. Ensure that the FROM statement in your Dockerfile points to the correct image location.
  4. Network Configuration:

    • Ensure that there are no network issues preventing Docker from accessing localhost:5002. You can test connectivity by:
      curl http://localhost:5002/v2/
      
  5. Use Remote Registry:

    • If you do not need to use a local registry, you can pull the base image from a remote registry. Modify your Dockerfile to use the correct remote image reference.
  6. Dockerfile Example:

    • Here is an example of how your Dockerfile might look if you are pulling from a remote registry:
      FROM torizon/qt6-wayland-imx8:3.3.1
      # Add your application build steps here
      
  7. Rebuild and Push:

    • After ensuring the base image is accessible, try rebuilding and pushing your Docker image again:
      docker build -t my-qt-app .
      docker tag my-qt-app my-dockerhub-user/my-qt-app:v1.0
      docker push my-dockerhub-user/my-qt-app:v1.0
      
  8. Run and Enable Service:

    • Once the image is successfully pushed and pulled, you can run it and enable it as a service:
      docker run -d --name my-qt-app --restart=always -v /dev:/dev --privileged my-dockerhub-user/my-qt-app:v1.0
      sudo systemctl enable my-qt-app.service
      sudo systemctl start my-qt-app.service
      

If you continue to face issues, please provide more details about your Dockerfile and the exact steps you are following, so I can assist you further.

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

Docker build error arm64v8-debian-weston-vivante:buster.

Hello @ToradexAI ,
I have docker file as below

# ARGUMENTS --------------------------------------------------------------------
## SDK container version
ARG SDK_BASE_VERSION=3.3.1
## Base container version
ARG BASE_VERSION=3.3.1
## Board architecture (default to 'arm64' if not provided)
ARG IMAGE_ARCH=arm64
## Board GPU vendor prefix (default to empty if not provided)
ARG GPU=
## Directory of the application inside the container
ARG APP_ROOT=/app

# BUILD ------------------------------------------------------------------------
    FROM --platform=linux/${IMAGE_ARCH} \
    localhost:5002/qt6-wayland-imx8:${SDK_BASE_VERSION} AS build


# Re-declare arguments for the build stage
ARG IMAGE_ARCH
ARG GPU
ARG APP_ROOT

# Copy the application source code into the container
COPY . ${APP_ROOT}
WORKDIR ${APP_ROOT}

# Clean previous builds
RUN rm -rf ${APP_ROOT}/build-${IMAGE_ARCH}

# Build the application depending on architecture
RUN if [ "$IMAGE_ARCH" = "arm64" ]; then \
        cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -Bbuild-${IMAGE_ARCH}; \
    elif [ "$IMAGE_ARCH" = "arm" ]; then \
        cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -Bbuild-${IMAGE_ARCH}; \
    else \
        echo "Unsupported architecture: $IMAGE_ARCH" && exit 1; \
    fi

# Compile the application
RUN cmake --build build-${IMAGE_ARCH}

# DEPLOY -----------------------------------------------------------------------
    FROM --platform=linux/${IMAGE_ARCH} \
    localhost:5002/qt6-wayland-imx8:${BASE_VERSION} AS deploy


# Re-declare arguments for the deploy stage
ARG IMAGE_ARCH
ARG GPU
ARG APP_ROOT

# Expose the SSH port for remote debugging
EXPOSE 2231
ARG SSHUSERNAME=torizon

# Avoid interactive prompts during installation
ENV DEBIAN_FRONTEND="noninteractive"

# Copy the compiled binaries from the build stage
COPY --from=build ${APP_ROOT}/build-${IMAGE_ARCH}/bin ${APP_ROOT}

# Set the working directory to the application root
WORKDIR ${APP_ROOT}

# Specify the command to run the application
CMD ["./test"]

and I have apply all above command but i am not able to deploy application

Greetings @Ravi1,

Couple of things I noticed.

First of all, the error you got is a docker build error correct? Where are you performing the actual build step? Is this on your development PC, or the Toradex device?

Second, as per your error message and Dockerfile, the issue is that the docker build is having issues fetching the base container image localhost:5002/qt6-wayland-imx8:3.3.1. Why is the base image coming from localhost:5002? Did you customize this Dockerfile?

The Dockerfile looks like it was generated from our extension templates. But none of our templates look for the base image at localhost:5002.

Finally, if your ultimate goal is to deploy your application to the device, then why are you performing these commands manually? You are using our VSCode extension correct? There should be premade tasks you can execute to automate the deployment process: Build, Test and Push Applications for Production | Toradex Developer Center

Best Regards,
Jeremias

Hello @jeremias.tx
First The all error i got is a docker build error and I am performing the build step in my development PC. Because I need to permanent deploy the application on My device so I need to create .tar file from docker image That is why I am Applying the all above command in My development PC.

second the issue is that the docker build is having issues fetching the base container image localhost:5002/qt6-wayland-imx8:3.3.1 . Yes I have customized my docker file also but I am fresher in this so i Don’t have that much of knowledge but the customized Docker file I have mentioned in previous message.

and Yes My ultimate goal is that I want to deploy the application to the device and I am using the VSCode extension than how should i use premade task.
If i am execute automate deployment process using the Torizon ArmV8 in this case i have to deploy application each and every time.
so can you please guide me for the docker file code as I have mentioned earlier in the chat

Because I need to permanent deploy the application on My device so I need to create .tar file from docker image That is why I am Applying the all above command in My development PC.

Why exactly do you need to create a tar file of your docker image? In your commands you’re going to push the image to Dockerhub, then pull it on the device right? If the docker pull will put the docker image on the device then what’s the tar file for?

Yes I have customized my docker file also but I am fresher in this so i Don’t have that much of knowledge but the customized Docker file I have mentioned in previous message.

It could be important to this issue the reason why your Dockerfile was modified like this. The way you have it modified right now you’re telling the Dockerfile to fetch the base image qt6-wayland-imx8:3.3.1 from localhost:5002 instead of Dockerhub. For example look at how the base container images are referred to in out default templates: vscode-torizon-templates/cppQML/Dockerfile at dev · toradex/vscode-torizon-templates · GitHub

Right now when you do docker build, it’s trying to look at localhost:5002 which would mean on your development machine. Do you even have a locally hosted registry with these base container images on that PC? If not, then please revert your Dockerfile to resemble the initial template. (i.e. commontorizon/qt6-wayland${GPU}:${SDK_BASE_VERSION})

If i am execute automate deployment process using the Torizon ArmV8 in this case i have to deploy application each and every time.

Why would you need to deploy the application every time? If you deploy it once the container image will now be on the device, isn’t that what you want? You would only need to deploy it again, if you want to change/update the container image/application later on.

Just start by fixing your Dockerfile so all the FROM statements are not pointing to localhost:5002. Unless you can recall why this modification was done in the first place.

Best Regards,
Jeremias

Hello @jeremias.tx,
Can you share any Example Video how to permanently deploy the application because I have tried all above steps but still I am not able to deploy Application permanently.

Best Regards
Ravi Vanand

Could you please share what exact steps you just tried. As well as what happened exactly when you did those steps including any logs/error messages.

Best Regards,
Jeremias

Hello @jeremias.tx ,
when I have apply the steps you given it shows the below error,
build-container-image-sdk-arm64 failed with exit code 1

Regards
Ravi Vanand

We followed the description here: Build, Test and Push Applications for Production | Toradex Developer Center
and everything works.

  1. run-container-torizon-release- (this vscode-task builds, and runs the release container on your target device)
  2. create-production-image (this vscode-task builds a release container image and pushes it to a container registry, like DockerHub (or what you defined in your .vscode/settings.json))
  3. Afterwared you can use Torizon Cloud to deploy the update to all devices

Every vscode-task will print to the command line and you will see at which step it fails.
Try to reproduce the failing step manually to figure out the problem.

hi @dan
I have followed the above link and apply the all settings but still I am not able to deploy the application permanently on my Toradex device.

Regards
Ravi Vanand

As said by @dan and myself the standard tasks and process does work for us. It’s not clear what you’re doing here that is different. You’re saying you followed all the steps, but without more specific details it’s difficult for us to analyze what is going wrong on your side.

Best Regards,
Jeremias

@jeremias.tx @dan ,
I have A docker File As below

# ARGUMENTS --------------------------------------------------------------------

## SDK container version

ARG SDK_BASE_VERSION=3.3.1

## Base container version

ARG BASE_VERSION=3.3.1

## Board architecture

ARG IMAGE_ARCH=

## Board GPU vendor prefix

ARG GPU=

## Directory of the application inside container

ARG APP_ROOT=

# BUILD ------------------------------------------------------------------------

#FROM --platform=linux/${IMAGE_ARCH} \

#localhost:5000/commontorizon/qt6-wayland${GPU}:${SDK_BASE_VERSION} AS build

FROM --platform=linux/arm64 localhost:5000/commontorizon/qt6-wayland${GPU}:${SDK_BASE_VERSION} AS build

ARG IMAGE_ARCH

ARG GPU

ARG APP_ROOT

# Copy any pre-built dependencies here (if needed)

# COPY ./path/to/dependencies /usr/local/lib/

# for vivante GPU we need some “special” sauce

# This RUN statement is removed since it needs internet access

# You can pre-install dependencies and copy them instead.

# deps - Use local packages or pre-installed packages

# Uncomment and adjust to copy dependencies if you have local deb files

# COPY ./path/to/deb/packages/*.deb /tmp/

# RUN dpkg -i /tmp/.deb && rm -rf /tmp/.deb

COPY . ${APP_ROOT}

WORKDIR ${APP_ROOT}

# Clean the previous builds

RUN rm -rf ${APP_ROOT}/build-${IMAGE_ARCH}

# Build the application

RUN if [ “$IMAGE_ARCH” = “arm64” ]; then \

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -Bbuild-${IMAGE_ARCH}; \

elif [ “$IMAGE_ARCH” = “arm” ]; then \

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -Bbuild-${IMAGE_ARCH}; \

fi

RUN cmake --build build-${IMAGE_ARCH}

# DEPLOY -----------------------------------------------------------------------

FROM --platform=linux/${IMAGE_ARCH} \

localhost:5000/commontorizon/qt6-wayland${GPU}:${BASE_VERSION} AS deploy

ARG IMAGE_ARCH

ARG GPU

ARG APP_ROOT

# SSH for remote debug

EXPOSE 2231

ARG SSHUSERNAME=torizon

# Make sure we don’t get notifications we can’t answer during building.

ENV DEBIAN_FRONTEND=“noninteractive”

# Copy the application compiled in the build step to the $APP_ROOT directory

COPY --from=build ${APP_ROOT}/build-${IMAGE_ARCH}/bin ${APP_ROOT}

# “cd” (enter) into the APP_ROOT directory

WORKDIR ${APP_ROOT}

# Command executed in runtime when the container starts

CMD [“./test”]

# DEPLOY -----------------------------------------------------------------------

ARGUMENTS --------------------------------------------------------------------

SDK container version

ARG SDK_BASE_VERSION=3.3.1

Base container version

ARG BASE_VERSION=3.3.1

Board architecture

ARG IMAGE_ARCH=

Board GPU vendor prefix

ARG GPU=

Directory of the application inside container

ARG APP_ROOT=

BUILD ------------------------------------------------------------------------

TODO: cross compile x86 to arm

We will use emulation here

Build Step

FROM --platform=linux/${IMAGE_ARCH}
commontorizon/qt6-wayland${GPU}:${SDK_BASE_VERSION} AS build

ARG IMAGE_ARCH
ARG GPU
ARG APP_ROOT

for vivante GPU we need some “special” sauce

RUN apt-get -q -y update &&
if [ “${GPU}” = “-vivante” ] || [ “${GPU}” = “-imx8” ]; then
apt-get -q -y install
imx-gpu-viv-wayland-dev
; else
apt-get -q -y install
libgl1
libgles-dev
; fi
&&
apt-get clean && apt-get autoremove &&
rm -rf /var/lib/apt/lists/*

deps

RUN apt-get -q -y update &&
apt-get -q -y install
build-essential
cmake
qt6-base-private-dev
qt6-base-dev
qt6-wayland
qt6-wayland-dev
qt6-declarative-dev
qt6-declarative-private-dev
qml6-module-qtqml
qml6-module-qtqml-workerscript
qml6-module-qtcore
qml6-module-qtquick
qml6-module-qtquick-window
qml6-module-qtquick-controls
qml6-module-qtquick-layouts
qml6-module-qtquick-templates
libqt6opengl6-dev
# ADD YOUR PACKAGES HERE

DO NOT REMOVE THIS LABEL: this is used for VS Code automation

# __torizon_packages_build_start__
# __torizon_packages_build_end__

DO NOT REMOVE THIS LABEL: this is used for VS Code automation

&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

deps

COPY . ${APP_ROOT}
WORKDIR ${APP_ROOT}

Remove the code from the debug builds, inside this container, to build the

release version from a clean build

RUN rm -rf ${APP_ROOT}/build-${IMAGE_ARCH}

RUN if [ “$IMAGE_ARCH” = “arm64” ] ; then
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -Bbuild-${IMAGE_ARCH} ;
elif [ “$IMAGE_ARCH” = “arm” ] ; then
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -Bbuild-${IMAGE_ARCH} ;
fi

RUN cmake --build build-${IMAGE_ARCH}

BUILD ------------------------------------------------------------------------

DEPLOY -----------------------------------------------------------------------

Deploy Step

FROM --platform=linux/${IMAGE_ARCH}
commontorizon/qt6-wayland${GPU}:${BASE_VERSION} AS deploy

ARG IMAGE_ARCH
ARG GPU
ARG APP_ROOT

SSH for remote debug

EXPOSE 2231
ARG SSHUSERNAME=torizon

Make sure we don’t get notifications we can’t answer during building.

ENV DEBIAN_FRONTEND=“noninteractive”

for vivante GPU we need some “special” sauce

RUN apt-get -q -y update &&
if [ “${GPU}” = “-vivante” ] || [ “${GPU}” = “-imx8” ]; then
apt-get -q -y install
imx-gpu-viv-wayland-dev
; else
apt-get -q -y install
libgl1
libgles-dev
; fi
&&
apt-get clean && apt-get autoremove &&
rm -rf /var/lib/apt/lists/*

your regular RUN statements here

Install required packages

RUN apt-get -q -y update &&
apt-get -q -y install
file
curl
qt6-base-private-dev
qt6-base-dev
qt6-wayland
qt6-wayland-dev
qt6-declarative-dev
qt6-declarative-private-dev
qml6-module-qtqml
qml6-module-qtqml-workerscript
qml6-module-qtcore
qml6-module-qtquick
qml6-module-qtquick-window
qml6-module-qtquick-controls
qml6-module-qtquick-layouts
qml6-module-qtquick-templates \

DO NOT REMOVE THIS LABEL: this is used for VS Code automation

# __torizon_packages_prod_start__
# __torizon_packages_prod_end__

DO NOT REMOVE THIS LABEL: this is used for VS Code automation

&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

USER torizon

Copy the application compiled in the build step to the $APP_ROOT directory

path inside the container, where $APP_ROOT is the torizon_app_root

configuration defined in settings.json.

COPY --from=build ${APP_ROOT}/build-${IMAGE_ARCH}/bin ${APP_ROOT}

“cd” (enter) into the APP_ROOT directory

WORKDIR ${APP_ROOT}

Specify the command to run the application

CMD [“./test”]

Than I am run the code using torizon Armv8 and it will display the output on my toradex screen but whenever I want display my application on the Toradex display I have to deploy code every time using torizon Armv8

Regards
Ravi Vanand

Hello @jeremias.tx @dan ,
I Have follow the steps that you have provide in early discussion so I have shared the video of that .
so please guide me how to deploy it permanently
Deploy VS Code.rar (2.3 MB)

Regards
Ravi Vanand