What is Daytona?
Daytona is an open-source Development Environment Manager (DEM) that simplifies development workflows, enabling you to create reproducible development environments based on OCI containers. In this guide, Iโll walk you through the process of integrating Daytona with a python project by demonstrating how, I integrated my python project Askpixie made using Reflex Framework, step by step.
Install Daytona on your Machine
To begin, visit the official Daytona documentation for installation:
Daytona Documentation
Daytona supports multiple platforms, including:
Linux
Windows
macOS
Since Iโm using a macOS, I will proceed with the macOS installation.
Option 1: Install via Terminal (Recommended)
Run the following command directly in your terminal:
(curl -sf -L https://download.daytona.io/daytona/install.sh | sudo bash) && daytona server -y && daytona
This will install Daytona and start the server automatically.
Option 2: Manual Installation
If you prefer manual installation, you can install Daytona in your desired path. For me, itโs in the Documents folder.
- Download Daytona (ARM64 for Apple Silicon):
# ARM64/Apple Silicon
curl -sf -L https://download.daytona.io/daytona/v0.49/daytona-darwin-arm64 -o daytona
Note: For intel based macs, the above command is replaced with:
# x86-64/Intel-based
curl -sf -L https://download.daytona.io/daytona/v0.49/daytona-darwin-amd64 -o daytona
- Once downloaded, make the file executable:
chmod +x ./daytona
Installing Docker Desktop
Daytona requires Docker to run Workspaces. If you donโt have Docker installed:
Download and install Docker Desktop.
Start the Docker Desktop application to ensure it runs in the background.
Start the Daytona Server
Once Daytona is installed
- Open the terminal and navigate to the directory where Daytona is installed. For me, itโs in Documents:
cd ~/Documents
To start the Daytona server, run:
./daytona serve
Alternatively, you can just run:
./daytona
This will open the Daytona CLI, as shown below:
Here, press Enter on the daytona server
option to start the Daytona server daemon. The CLI will prompt you to confirm:
Once you click Yes, the Daytona server daemon will start, and you should see this message:
Set Up Git Provider
To connect Daytona to your GitHub repository:
Open the Daytona CLI.
Select daytona git-provider add
it will show this type of window:
Since my project is hosted on GitHub, I will select GitHub.
It will then ask for a Personal Access Token
You can get more details about creating PAT from here
Note: While creating PAT give this access to:
repo
read:user, user:email
admin:repo_hook
After giving PAT, you can choose Commit Signing Method:
You can get more details about signature verification from here.
Once you complete all this your Git provider will be registered.
Set Up a Cloud Provider
To manage cloud environments such as AWS, Azure, or GCP, youโll need to install the necessary cloud provider. Run this command to set it up:
./daytona provider install
Select Your Development Environment
A "Target" refers to the platform where your environment will run, such as Docker (local or remote), AWS, GCP, or other cloud services. Choose your target by running this command:
./daytona
Then, select daytona target set from the CLI options:
I am running my environment locally using Docker, so I select local-docker.
Configure Your IDE
Daytona allows seamless integration with a range of IDEs, such as VS Code, IntelliJ, and others. To set up your preferred IDE, run the following command:
./daytona ide
I am using VSCode (browser) one, but you can use any IDE of your choice.
Add the devcontainer.json
to Your Repository
Create a .devcontainer/devcontainer.json
file to define the development container setup. This file configures your development environment and ensures that all required dependencies are automatically installed.
You can manually create a devcontainer.json
file, or use tools like Devcontainer AI to generate one for you. Below is the devcontainer.json I used for Askpixie:
Create a Daytona Workspace
Now that Daytona is connected to GitHub and your cloud provider is set, itโs time to create a workspace. Run the following command and provide the URL of your GitHub repository:
./daytona create <github repo url>
Daytona will fetch your repository, create a workspace, and provision the development environment.
You Are All Set!
Daytona will now open your project in the selected IDE, and you can start developing your project without any setup headaches!
Troubleshooting: Permission Denied Error
On macOS, you might encounter a permission denied error while starting the Daytona server. To resolve this, use the following command to grant executable permissions:
chmod +x ./daytona
Avoid using sudo to change permissions, as it can cause issues with workspace creation. The chmod command should resolve the issue.
Conclusion
By following this guide, youโve successfully integrated Daytona within your project and set up a smooth development environment. Daytona simplifies managing reproducible development environments, allowing you to focus on what matters most โ coding!
Top comments (0)