Skip to main content
Version: Torizon OS 6.x.y

Build, Test and Push Applications for Production

Introduction

The Torizon IDE Extension offers multiple tasks for managing application containers after the debugging phase is complete:

Prerequisites

Build and Test Release Container Images

You can build and run containers through the run-container-torizon-release-<arch> task, which performs the following steps:

  1. Build a container image based on Dockerfile.
  2. Push the container image to the local container registry (localhost:5002).
  3. Pull the container image to your SoM set as the default target.
  4. Run the container on your SoM using the docker-compose.yml configuration.

When debugging applications, the container is built based on Dockerfile.debug. That file contains additional dependencies and settings to enable remote debugging on VS Code. Instead, the run-container-torizon-release-<arch> task builds the container with only the essential configuration. You can use that task to test your application before moving it to production.

To run run-container-torizon-release-<arch> task, follow the steps below:

  1. Click on the Explorer icon located on the VSCode Activity bar.
  2. Open the TASK RUNNER tab.
  3. Click on the task.

Prepare your Application Container for Production

The create-production-image task performs the following steps:

  1. Build a container image based on Dockerfile.
  2. Push the container image to a container registry, such as DockerHub.
  3. Create the docker-compose.prod.yml file.

The docker-compose.prod.yml file is automatically created based on docker-compose.yml:

  • The -debug services are removed.
  • Environment variables, such as DOCKER_LOGIN and TAG, are replaced with user inputs.
  • The build configuration is removed.

You can use the .yml file to create application packages on Torizon Cloud.

warning

Do not edit the docker-compose.prod.yml file. To change the rules or services of docker-compose.prod.yml, edit the docker-compose.yml file and run the create-production-image task again.

When triggered, the create-production-image task requires the following inputs:

  • Docker registry: The container registry to which the task pushes the image. If empty, the task uses DockerHub. However, you can use any other registry, like GitHub and Azure.

  • Docker registry user login: The task uses the user login to set the image's name, which will be userLogin/applicationName:dockerTag.

  • Docker registry password: the Docker registry password or token to use to push the image to the container registry. This will be stored as a secret in the VS Code vault.

  • Docker tag to use in the production image: The container tag. The image name will be userLogin/applicationName:dockerTag.

  • Container architecture: The platform architecture to which the task compiles the container. Select the architecture that matches your target device.

Some inputs such as the container tag are not requested again if previously set. To change input values, edit .vscode/settings.json. For input details, see Workspace Settings.

At the finish of the task, the VS Code terminal should display the following message:

Build and Push Applications to Torizon Cloud

You can push applications to Torizon Cloud directly from the Torizon IDE extension. The tcb-platform-publish task runs create-production-image and pushes the docker-compose.prod.yml file to Torizon Cloud, creating a new application package.

Before running the tcb-platform-publish task, proceed as follows:

  1. Get Torizon Cloud credentials.zip.
  2. Place the credentials.zip file in the root directory of your project (where Dockerfile and docker-compose.yml are located).

When triggered, the tcb-platform-publish task requires the following inputs:

  • The create-production-image inputs described in the previous section.
  • Torizon Cloud API v2 Client ID.
  • Torizon Cloud API v2 Client Secret.

See Creating a New Torizon Cloud API v2 Client for information about the API credentials.

At the finish of the task, you should see the following message in the terminal tab:

The application package will be available on Torizon Cloud:



Send Feedback!