Testing Locally with Docker
We provide a Docker container that makes task development very seamless and straightforward. We chose to use Docker in order to provide all the required task development resources in a consistent and isolated environment.
Install Docker here:
Based on the different operating systems, the installation steps might be different. After fully setup the docker follows the steps below to run the task environment.
The Docker container provided is an integration of Redis, task-node, and K2 in one environment. The complete architecture for task development will be configured after running the Docker container. There's no need to clone the K2 repo or run the test validator locally; K2 is automatically configured and a staking wallet is created for you.
Clone the task environment repository, and you should have a project with a folder structure similar to the one below:
.env.examplefile contains a list of environment variables and their descriptions.
To run the task environment, run the command below:
docker compose up --build
Following the execution of the command above, three Docker images are created:
task-node. All required dependencies are installed, and the complete stack for task creation is set up for you.
Now that the task environment is set up, you can create a new task. Refer here to learn how to create a task. Configure your RPC URL to point to the test validator running on Docker, which is
http://localhost:8899. Run the command below to change your RPC URL to point to the test validator running on Docker:
koii config set --url localhost
koii config get
After creating a new task, add the task ID to the
TASKSvariable in the task-environment directory. You can add more than one task by separating the IDs with a comma. After adding your task ID(s), you can run
docker compose up --buildagain to build the container and run the task(s).