Skip to main content
Version: 6

Build and Push Applications

Introduction​

In this article you will learn how to build and push your application containers using Torizon IDE Extension 2. This will provide you with a ready-to-deploy container images. You will also learn how to push to DockerHub and Torizon Cloud, leveraging the automated tasks from the Extension.

Prerequisites​

Build only:

Push to DockerHub:

Push to Torizon Cloud:

Build and Push the Production Docker Image​

Use one of the push-release-<arch\> tasks.

These tasks can build the application based in the production Dockerfile and push the image to the DockerHub. The image will be dockerUserLogin/applicationName:archSelected.

There is one task for each architecture supported by Torizon OS:

  • push-release-arm64
  • push-release-arm
  • push-release-amd64

Inputs are needed to complete the task and are asked in the start of the task:

  • Docker registry user login: the Docker registry user login to use to push the image to DockerHub.
  • Docker registry password: the Docker registry password to use to push the image to DockerHub. This will be stored as a secret in the VS Code vault.

Build, Push and Generate the Docker-compose for Production​

After the project development cycle is finished, the next step is to generate a production image. The production image is the image that will be used to create a package to push to Torizon Cloud.

The production image is generated using the create-production-image task. This task has automation steps to build the production Docker image and push it to the DockerHub registry. The production Docker image is based in the Dockerfile file.

Inputs are needed to complete the task and are asked in the start of the task:

  • Docker namespace: the Docker namespace to use to build the image, push it to DockerHub and set in the docker-compose.prod.yml. The image name will be dockerNamespace/applicationName:dockerTag.
  • Docker tag to use in the production image: the Docker tag to use in the production image. The image name will be dockerNamespace/applicationName:dockerTag.
  • Docker registry password: the Docker registry password to use to push the image to DockerHub. This will be stored as a secret in the VS Code vault.
  • Container architecture: the architecture to build the Docker image. This will be shown as itens to select. Select the architecture that matches the target device.

Wait for the task to finish. The production Docker image will be built and pushed to DockerHub. The docker-compose.prod.yml file will be updated with the new image and version set by the user inputs, you should have something like the image below in the terminal tab on the finish of the task:

This is the flow of the create-production-image task:

  • Build the application Docker image based in the Dockerfile;
  • Push the application Docker image to the DockerHub registry;
  • Generate the production docker-compose.prod.yml file;

The generated docker-compose.prod.yml file is based on the docker-compose.yml file, the -debug services are removed and environment variables are set to production values. This file can be used to create a new docker-compose package in Torizon Cloud.

Warning

The generated docker-compose.prod.yml file is not intended to be edited manually. If you need to change some rule or service in the docker-compose.prod.yml file, you need to edit the docker-compose.yml file and run the create-production-image task again.

Build and Push the Application to Torizon Cloud​

Use the tcb-platform-publish task. This task will build the production image based on the Dockerfile, push it to DockerHub, create the docker-compose and push it to the Torizon Cloud. This creates a new application package ready for updates in Torizon Cloud.

Warning

This task needs the credentials.zip file from Torizon Cloud in the root of the project folder. You can get it from the Torizon Cloud. Check the How to Get Torizon Cloud credentials.zip documentation for more information.

After you have generated a production image, and the docker-compose.prod.yml, you can create a Torizon Cloud docker-compose package. This package can be used to deploy, or trigger an update, to a device fleet.

alt

Inputs are needed to complete the task and are asked in the start of the task:

  • Docker registry password: the Docker registry password to use to push the image to DockerHub. This will be stored as a secret in the VS Code vault.
  • Container architecture: the architecture to build the Docker image. This will be shown as itens to select. Select the architecture that matches the target device.

  • Docker namespace: the Docker namespace to use to build the image, push it to DockerHub and set in the docker-compose.prod.yml. The image name will be dockerNamespace/applicationName:dockerTag.
  • Docker tag to use in the production image: the Docker tag to use in the production image. The image name will be dockerNamespace/applicationName:dockerTag
Warning

The Docker tag to use in the production image input is shown only if the docker_tag property is not set in the .vscode/settings.json. See Workspace Settings for more information.

At the end of the tasks, if all was successful, you will see the following message in the terminal tab:

alt

And the package will be available in the Torizon Cloud:

alt



Send Feedback!