VSCode Dev Container

When developing with Nyra, it’s typically advised to perform compilation and development within a containerized environment. However, if you’re using VSCode outside of the container, you may encounter issues with unresolved symbols. This occurs because certain environment dependencies are installed within the container, and VSCode outside the container cannot access its environment, leading to missing header files.

To address this, you can mount VSCode within the container to allow it to recognize the container's environment and resolve the header files correctly. This guide will walk you through using VSCode’s Dev Containers and Docker extensions to set up this environment seamlessly.

Step 1: Install the Docker Extension

First, install the Docker extension in VSCode. This extension allows you to manage Docker containers directly within VSCode.

Step 2: Install the Dev Containers Extension

Next, install the Dev Containers extension. This extension enables VSCode to connect to Docker containers for development.

Step 3: Start the Development Environment Using Docker Compose

This step is similar to the process outlined in the Quick Start guide. However, instead of running:

>_Terminal
docker compose up

Using the docker compose up -d command, start the container in detached mode:

>_Terminal
docker compose up -d

After executing this command, the container will start. Open VSCode, navigate to the Docker extension, and you should see the container listed as running.

Step 4: Connect to the Container

In the Docker extension within VSCode, locate the astra_agents_dev container in the list of available containers and click on Attach Visual Studio Code to establish a connection to the container. This action will open a new VSCode window that is directly connected to the container, allowing you to continue your development work.

When working within the Dev Container, be aware that your local extensions and settings won’t automatically apply, as you’re now operating within the containerized environment. As a result, you'll need to install the necessary extensions and configure settings directly inside the container. To do so, open the new VSCode window, click on the Extensions icon in the left sidebar, search for the required extensions, and follow the prompts to install them within the container.

Step 5: Setup breakpoint for debugging

Setting breakpoints is a standard technique for debugging. To set a breakpoint, simply click on the left margin next to the line number where you wish to pause execution. A red dot will appear, signaling that the breakpoint has been successfully set.

Setting Breakpoint

If you're unable to set a breakpoint, it typically indicates that the necessary language extension is not installed within the container. To resolve this, navigate to the Extensions tab in the left sidebar, search for the required language extension, and follow the prompts to install it within the container environment.

After successfully setting the breakpoint, initiate debugging by selecting the Run and Debug icon in the left sidebar. Choose the appropriate Python debug configuration, then click the green play button to begin the debugging session.

Debug Configuration

In this way, VSCode is directly starting the agent application, which means Golang web server is not paticipating in the run. Therefore, you will need to pay attention to below points:

Which graph is being used in this mode?

The web server facilitates the manipulation of property.json when initializing the agent, allowing you to specify the desired graph. However, in this mode, you will need to manually edit property.json to choose the graph. By default, Nyra will automatically select the first graph with the auto_start property set to true for initialization.

RTC properties

The RTC feature is essential for enabling communication between your client and the agent server. The web server will automate the generation of RTC tokens and channels, updating these details in property.json for you. However, in this manual mode, you will need to manually edit property.json to add the RTC tokens and channels yourself. The most straightforward approach is to first run the playground/demo, which will generate a temporary property file. You can then copy the RTC tokens and channels from that file.

The path to the temporary property file can be found in the ping request logs, as shown below,

2025/01/01 08:39:19 INFO handlerPing start channelName=agora_74np6e requestId=218f8e36-f4d0-4c83-a6e8-d3b4dec2a187 service=HTTP_SERVER
2025/01/01 08:39:19 INFO handlerPing end worker="&{ChannelName:agora_74np6e HttpServerPort:10002 LogFile:/tmp/astra/app-agora_74np6e-20241123_083855_000.log Log2Stdout:true PropertyJsonFile:/tmp/astra/property-agora_74np6e-20241123_083855_000.json Pid:5330 QuitTimeoutSeconds:60 CreateTs:1732351135 UpdateTs:1732351159}" requestId=218f8e36-f4d0-4c83-a6e8-d3b4dec2a187 service=HTTP_SERVER

The temp property file path is shown as PropertyJsonFile:/tmp/astra/property-agora_74np6e-20241123_083855_000.json.

Last updated