# Contents

Having a consistent, reliable, and efficient development environment is crucial. However, setting up and maintaining such environments can be a significant challenge, often leading to frustration, wasted time, and reduced productivity. This is where Daytona comes in.

Daytona is an open-source development environment manager that allows you to set up a fully configured development environment with a single command. It's designed to work seamlessly across various infrastructures, whether local, remote, cloud-based, or on physical servers.

One of Daytona's most powerful features is its ability to work with remote profiles, allowing you to run a Daytona server on a remote machine and manage your development environments from anywhere. If you're feeling adventurous, you can even run multiple machines and manage various profiles simultaneously.

This guide will walk you through the process of setting up Daytona with a remote profile, enabling you to harness the full power of remote development.

Why Use Daytona with Remote Profiles?

Utilizing remote profiles instead of remote targets provides greater flexibility, as the Daytona server operates on the remote machine. This setup allows you to manage your workspaces from that machine, enabling you to easily switch between different local devices—such as your office and home computers or your laptop and desktop—while still maintaining access to all your workspaces.

Before we go into the setup process, let's consider why you might want to use Daytona:

  1. Resource Efficiency: By running development environments on remote machines, you can leverage more powerful hardware without upgrading your local machine.

  2. Flexibility: Work from anywhere, on any device, with your full development environment always accessible.

  3. Scalability: Easily scale your development resources up or down as needed, without affecting your local setup.

  4. Security: Keep sensitive code and data on secure remote servers instead of local machines.

Now, let's get started with setting up Daytona on a remote machine.

Step-by-Step Guide

1. Prepare the Remote Machine

First, you'll need a remote machine to host your Daytona server. This could be a cloud instance, a bare metal server, or any machine you can access via SSH. For this guide, we'll use an Equinix Metal bare metal server.

  1. Create a new machine on your chosen platform. In this example, we're using a small Equinix Metal server with 8 cores and 32GB RAM running Ubuntu 22.04 operating system.

  2. Once the machine is provisioned, note down its IP address.

  3. Connect to the machine via SSH:

1 ssh root@<your-server-ip>
  1. Update the server:

1 sudo apt update

2. Create a New User

It's a good practice to create a dedicated user for Daytona:

  1. Create a new user named 'daytona':

1 sudo adduser daytona
  1. Add the user to the 'daytona' and 'sudo' groups:

1 sudo usermod -aG daytona daytona
2 sudo usermod -aG sudo daytona

3. Install Required Tools

  1. Install systemd-container, which provides tools to manage containers:

1 sudo apt install systemd-container
  1. Switch to the daytona user:

1 machinectl shell daytona@.host
  1. Install Docker following the official Docker documentation:

1 sudo apt-get install ca-certificates curl
2 sudo install -m 0755 -d /etc/apt/keyrings
3 sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
4 sudo chmod a+r /etc/apt/keyrings/docker.asc
5 echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
6 sudo apt-get update
7 sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  1. Verify Docker installation:

1 sudo docker run hello-world
  1. Change Docker socket permissions:

1 sudo chmod 666 /var/run/docker.sock

4. Install and Configure Daytona on Remote Server

Now that we've set up the server, we can finally install Daytona and begin working.

  1. Install Daytona:

1 (curl -sf -L https://download.daytona.io/daytona/install.sh | sudo bash) && daytona server -y
  1. Check Daytona version:

1 daytona version
  1. Enable lingering for the daytona user, allowing the user to run persistent services even when not logged in:

1 loginctl enable-linger daytona
  1. Generate an API key:

1 daytona api-key generate

Note down the generated API key or just copy the proposed command that you need to run on the client machine. It should resemble the following example (please remember that you shouldn't copy and paste the command below, as it is intended for illustrative purposes only):

1 daytona profile add -a \
2 https://api-e5829d38-205d-4720-aadb-d2ccccccc994.try-eu.daytona.app \
3 -k ZGZiNjdmMjItNCCiMC00YTYzL11wOFRtZmE3YTM3YjFhMmEw

5. Configure Daytona on Your Local Machine

  1. Open a terminal on your local machine.

  2. Run the Daytona profile command with the new API key or copy the command you have been provided in the previous step:

1 daytona profile add --name <profile-name> --url <remote-server-ip>:3000 --api-key <your-api-key>

Replace <profile-name>, <remote-server-ip>, and <your-api-key> with your actual values.

  1. The new profile should be set as active, but you can also activate it using the following command:

1 daytona profile use <profile-name>

6. Configure Git Providers

To use your Git repositories with Daytona, you need to configure Git providers:

  1. Run the Git providers setup command:

1 daytona git-providers add
  1. Follow the prompts to add your preferred Git provider (e.g., GitHub, GitLab, Bitbucket).

7. Create Your First Development Environment

Now you're ready to create your first remote development environment:

  1. Run the create command:

1 daytona create
  1. Follow the prompts to select your Git repository and configure your environment.

  2. Once the environment is created, you can access it using:

1 daytona code

Conclusion

Congratulations! You've successfully set up Daytona with a remote profile. This powerful configuration allows you to leverage the benefits of remote development while maintaining a consistent and efficient workflow.

Remember, Daytona is highly customizable and extensible. As you become more familiar with the platform, explore its advanced features, such as custom providers and plugins, to tailor your development environment to your specific needs.

By using Daytona with remote profiles, you're taking a significant step towards more efficient, consistent, and flexible software development. Happy coding!

Tags::
  • profiles
  • remote
  • sde
  • equinix