DEV Community

Cover image for Daytona Integration: A Step-by-Step Guide to Deploying ML Models
POTLURI KRISHNA PRIYATHAM
POTLURI KRISHNA PRIYATHAM

Posted on

Daytona Integration: A Step-by-Step Guide to Deploying ML Models

Introduction

This is an article cum tutorial where I am going to describe my experience in adopting Daytona in my project building and also demonstrate the step-by-step process of how I adopted Daytona.

Let us divide the entire article into sections.

  • About Daytona
  • My experience
  • Step-by-step tutorial

About Daytona

Daytona is an open-source development environment manager software. It works based on the containerization of the entire development environment. With Daytona, we, as developers, can set up and run entire development environments, including all dependencies, using a single devcontainer.json file. We can run the environment with just two commands once the environment is set up. Daytona company also owns and maintains other great projects like ai-enablement-stack, backstage, and devcontainer.ai. It also owns and maintains other projects that work as extensions to Daytona.

My experience

Installing Daytona and setting up the environment for the first time has been very hectic. Thanks to devcontainer.ai, I could generate a devcontainer.json file. By AI or skill, creating the correct devcontainer.json file is the key to the smooth setup of your project. I couldn't get the correct JSON file from the AI, so I had to delete a few files, like Jupyter Notebook, to get the appropriate image for containerization.

After many failed and successful iterations of building and running the development, I have found the perfect flow of setting up and running a project in a git repo with a devcontainer.json file. Using the devcontainer.json, I have also learnt to create development containers independent of Daytona using "Dev Containers" under "Remote Development" in JetBrains' Pycharm Professional. I have learned the actual value of containerization and docker with all the processes I have completed.

Daytona Daemon

list of Daytona workspaces

Step-by-step tutorial

Note: This tutorial demonstrates the process of creating development containers with the development environment using Daytona for Windows machines.

  1. Download the daytona.exe file from

    https://download.daytona.io/daytona/latest/daytona-windows-amd64.exe
    

    or

    https://download.daytona.io/daytona/latest/daytona-windows-arm64.exe
    
  2. Add to Path and create a new environment variable with "daytona" as
    the variable name and "path/to/daytona.exe" as the variable value.

  3. Create the file ".devcontainer/devcontainer.json" in the home
    directory of your git repo. To create the file, you can either depend
    upon AI or your skill. You can also refer
    the below sample file.
    Note: Daytona currently accepts only online repos (GitHub/gitlab/bitbucket/etc).

    {
      "name": "Python Flask Application",
      "image": "mcr.microsoft.com/devcontainers/python:3.12-bookworm",
      "forwardPorts": [
        5000
      ],
      "customizations": {
        "vscode": {
          "settings": {
            "python.defaultInterpreterPath": "/usr/local/bin/python",
            "python.linting.enabled": true,
            "python.linting.pylintEnabled": true,
            "python.formatting.autopep8Path": "/usr/local/bin/autopep8",
            "python.formatting.blackPath": "/usr/local/bin/black",
            "python.linting.banditPath": "/usr/local/bin/bandit",
            "python.linting.flake8Path": "/usr/local/bin/flake8",
            "python.linting.mypyPath": "/usr/local/bin/mypy",
            "python.linting.pycodestylePath": "/usr/local/bin/pycodestyle",
            "python.linting.pydocstylePath": "/usr/local/bin/pydocstyle"
          },
          "extensions": [
            "ms-python.python",
            "ms-python.vscode-pylance"
          ]
        }
      },
      "postCreateCommand": "pip install -r requirements.txt"
    }
    
  4. Start the daytona server using the command:

    daytona serve
    

    Starting Daytona Server

  5. In a new terminal, create a workspace using the command: (replace with your repo link)

    daytona create <repo>
    
  6. run your workspace with the command:

    daytona run
    
  7. Select Linux

    VS Code starting workspace

  8. Check the checkbox and Click on "Yes, I trust the authors".

    Trusted Authors

  9. Run your app with command applicable for your tech stack. For example:

    flask run
    

    or

    python -m flask run
    

    or

    python app.py
    

Top comments (0)