DEV Community

Cover image for Using Daytona to maintain a Development Environment
Kanak Tanwar
Kanak Tanwar

Posted on

Using Daytona to maintain a Development Environment

As a developer and someone exploring Open Source, setting up new projects and configuring their development environments have been such a headache and a time eater.

I found Daytona in the Quira Quest 23. Our task was to use Daytona to configure and automate our development environment.

Sounds difficult? Not so much. Just 3 steps and I was all done.

1. Setup your project in you system

In my case this was already done. I had a RAG application that allows you to have a q/a session with any github repository of your choice.
It uses Daytona for managing environment, weaviate cloud vector database to store the embeddings, LangChain with OpenAI for llm models and facilitate queries with context and streamlit for UI.

2. Create a .devcontainer/devcontainer.json file in the root dir of the project.

3. Generate a devcontainer.json

Go to DevContainer.ai, create your own devcontainer.json using AI and paste its content in the file you created.

{
  "name": "Git Chat Development Environment",
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu", 
  "features": {
    "python": "3.10"
  },
  "forwardPorts": [
    8501
  ],
  "customizations": {
    "vscode": {
      "settings": {
        "python.defaultInterpreterPath": "${workspaceFolder}/gitchat-venv/bin/python",
        "python.linting.enabled": true,
        "python.linting.pylintEnabled": true,
        "python.formatting.autopep8Path": "${workspaceFolder}/gitchat-venv/bin/autopep8",
        "python.formatting.blackPath": "${workspaceFolder}/gitchat-venv/bin/black",
        "python.linting.flake8Path": "${workspaceFolder}/gitchat-venv/bin/flake8",
        "python.linting.mypyPath": "${workspaceFolder}/gitchat-venv/bin/mypy",
        "python.linting.pydocstylePath": "${workspaceFolder}/gitchat-venv/bin/pydocstyle",
        "python.linting.pycodestylePath": "${workspaceFolder}/gitchat-venv/bin/pycodestyle"
      },
      "extensions": [
        "ms-python.python",
        "ms-python.vscode-pylance",
        "njpwerner.autodocstring"
      ]
    }
  },
  "postCreateCommand": "python -m venv gitchat-venv && . gitchat-venv/bin/activate && pip install -r requirements.txt"
}
Enter fullscreen mode Exit fullscreen mode

And you are done. That's it.
But what are the benefits of this you ask?
Here you go.
Benefits of Dev Containers

How Daytona comes into play

Daytona abstracts a lot of steps and allows you to setup development containers without much effort. It simplifies the process of managing environments by providing a clean, modular workspace. Instead of manually cloning repositories, setting up environments, and troubleshooting dependencies, Daytona handles it with a few commands.

Getting started with Daytona

Documentation Β· Daytona

Start managing your Workspaces with Daytona.

favicon daytona.io

The daytona documentation is very easy to go through. Here I will be going through some basic steps to setup and use Daytona. You can browse the docs for detailed info.

1. Installing Daytona

For Linux, run this in your shell:

(curl -sf -L https://download.daytona.io/daytona/install.sh | sudo bash) && daytona server -y && daytona
Enter fullscreen mode Exit fullscreen mode

Checkout the installation guide for other OS.

2. Configurations

  • git providers
daytona git-providers add
Enter fullscreen mode Exit fullscreen mode

This helps you work with git and manage your repositories. There are a number of options like github, gitlab, bitbucket etc.

  • providers
daytona provider install
Enter fullscreen mode Exit fullscreen mode

This allows you to connect to a provider like GCP, AWS etc.

  • set target
daytona target set
Enter fullscreen mode Exit fullscreen mode

target is the location where you want to set up your development environment.
Select docker if you want to set it up locally on you system.
Select the configurations as they popup. I used all the default configs with docker server.

  • select ide
daytona ide
Enter fullscreen mode Exit fullscreen mode

Daytona allows you to work with you preferred IDE out of the box without you configuring various things. You can also include IDE specific settings in you .devcontainer/devcontainer.json file to customize the dev env further.

3. Create Workspace

A workspace is a dedicated development environment for the project you are working on.

This can be done simply with the following command:

daytona create https://github.com/kanakOS01/gitchat-daytona
Enter fullscreen mode Exit fullscreen mode

This is my project url which has a .devcontainer/devcontainer.json file. You can replace this with any repo which has a devcontainer.json file in it.

You can find a list of sample repos which you can try out here.

My Takeaways from Using Daytona

  • Time Saved: By automating repetitive setup tasks, Daytona allowed me to focus on building Git Chat’s core functionality.
  • Consistency Across Environments: Whether I worked locally or collaborated with others, Daytona ensured the environment was identical every time.
  • Ease of Use: The intuitive CLI commands and clear documentation made Daytona accessible even for someone trying it for the first time.

Top comments (1)

Collapse
 
aarushi_bhatia_578922f673 profile image
Aarushi Bhatia

A Good read πŸ‘