Choreo CLI: A practical guide to managing your applications in choreo

Charuka Karunanayake
Choreo Tech Blog
Published in
4 min readMar 27, 2024

CLI tools excel in efficiency and automation, offering swift execution of commands for streamlined tasks. Their scripting capabilities empower users to automate complex workflows, enhancing productivity and ensuring consistent task execution. This efficiency and automation make CLI tools a go-to choice for system administrators and DevOps professionals seeking optimal performance in computing workflows. In this realm, Choreo CLI emerges as a practical solution designed to enhance developer productivity. Integrated seamlessly into the Choreo platform, our Command Line Interface (CLI) offers a straightforward and powerful toolset for navigating modern application life cycles, streamlining your DevOps experience.

In this blog, we will look at how to incorporate Choreo CLI in your daily workflow.

What can you do with Choreo CLI?

  • Create and Manage Resources: Simplify project and component management with Choreo CLI. Developers can effortlessly initiate and organize projects, establishing an efficient development environment.
  • Create Builds and Deployments: Choreo CLI simplifies building and deploying applications. Developers can seamlessly initiate builds using straightforward commands, ensuring a smooth transition from development to deployment.
  • Monitor with Logs: Harness the power of integrated log functionality within Choreo CLI to monitor applications effectively. Developers can gain valuable insights into application behavior and performance by accessing logs directly from the command line.

Getting started

Install Choreo CLI by running the command specific to your operating system

  • For Linux and Mac OS
curl -o- https://cli.choreo.dev/install.sh | bash
  • For Windows(via PowerShell)
iwr https://cli.choreo.dev/install.ps1 -useb | iex

After installing you can verify your installation by running choreo -v

Choreo CLI in Action

Let’s look at how we can incorporate choreo CLI into our daily workflow, for this we will use one of the sample apps we have created the reading book list app. Please make a fork of this repo to start working.

1. To get started with the CLI we should first login

chroeo login

2. Creating a project to host our application

A project in Choreo is a logical group of related components that typically represent a single cloud-native application. A project consists of one or more components.

Create a mono-repository project called ‘book-list-app’ by running the following command

choreo create project book-list-app --type mono-repository

3. Creating a component in the project

In Choreo, a component within your project signifies a singular unit of work in a cloud-native application. This can take the form of a microservice, API, web application, or job/task. Each component is linked to a specific directory path in a Git repository, housing the source code for the program.

To initiate the creation of a backend service component, use the following command, which triggers a wizard prompting you to provide details for your Git repository and other necessary configurations for your component.

choreo create component backend-service --project book-list-app

For the sample we are working with the following inputs should be provided when prompted

  • Remote repository URL: <your repository URL>
  • Branch: main
  • Directory: reading-list-service
  • Build Pack: nodejs
  • Language Version: 20.x.x

4. Viewing the status of the component

To inspect the details of the created component, you can use the following command. This provides comprehensive information about the component, including basic details and service endpoint URLs once the services are deployed.

choreo describe component backend-service --project book-list-app

5. Build the component

To deploy your service you need to first build it in choreo, to do that run the following command

choreo create build backend-service --project book-list-app

6. View the build status

To check the status of a specific build, run the following command, replacing <build-id> with the actual build ID obtained from the previous command. Typically, a build takes approximately 2 to 5 minutes to complete.

choreo describe build <build-id> --project book-list-app --component backend-service

7. Viewing Logs

For verification or debugging you can use the logs command to view build logs once the build is completed.

choreo logs --type build --project book-list-app --component backend-service --build-id <build-id>

8. Deploying to the Development environment

Once the build status is successful, run the following command to deploy the component in the Development environment.

choreo create deployment backend-service --env=Development --project book-list-app --build-id <build-id>

9. Verify the deployment in the development environment

After deploying the service, you can inspect the status of the deployment using the component describe command and get the public URL that can be used for testing purposes..

choreo describe component backend-service --project book-list-app

The output looks like the following, and you can retrieve the public URL from the output

10. Testing the Service

To test the service you can obtain a test key using the following command

choreo create test-key --project book-list-app --component backend-service --env Development

Use the test key obtained by the above command to test the service you have deployed

curl -H "Api-Key: <key>" <public-url>

11. Deploy to the Production environment

Once your deployment has been verified in the devolopment environment you can deploy it to production using the following command.

choreo create deployment backend-service --env Production --project book-list-app --build-id <build-id>

Congratulations! You’ve successfully deployed your web application to the cloud using Choreo CLI.

--

--