Workspaces
Workspaces serve as isolated environments containing your project’s codebase, dependencies, packages, and configuration, providing a consistent and reproducible setup for development, testing, and deployment.
They ensure that changes in one project do not inadvertently affect another, promoting a more stable and reliable workflow. This is particularly beneficial in collaborative settings, as it ensures that all team members are working with the same configuration, reducing the likelihood of environment-related issues.
Create a Workspace
Creating a Workspace in Daytona is a straightforward process that ensures you have a dedicated development environment for your projects.
Daytona provides two primary methods for creating a Workspace:
From a Git Repository
Creating a Workspace from a Git repository sets up a new development environment using a connected Git Provider or a custom Git repository URL.
- Run the following command to create a Workspace from a Git repository:
- Select one of the three provided options:
-
Select from a List of Repositories
If you connected a Git Provider, you will be presented with a list of your repositories from which you can select to connect with your Workspace.
-
Enter a Custom Repository URL
Alternatively, select the option to enter a custom repository URL manually if the repository is not listed under your Git Provider account or is from an external source.
-
Create from Sample
If you do not have a Git repository ready, you can create a Workspace from a Sample project provided by Daytona. This option sets up a new development environment using quick-start templates.
-
Select the Git repository from the list, enter the URL of the Git repository you want to link with your Workspace, or choose to create a Workspace from a sample project.
-
Enter a name for your Workspace.
- Select a Target to deploy your Workspace to. Selecting a Target will prompt you to input the Target configuration. The configurations vary based on the selected Target.
Upon Target selection and configuration, Daytona will clone the specified Git repository and set up a new Workspace based on its contents. You will see progress information in the terminal, indicating the process of creating a Workspace.
From an Arbitrary Git URL
Creating a Workspace from an arbitrary Git URL sets up a new development environment by directly specifying the URL of the remote repository.
- Run the following command to create a Workspace from a remote Git repository:
Example
- Select a Target to deploy your Workspace to. Selecting a Target will prompt you to input the Target configuration. The configurations vary based on the selected Target.
Upon Target selection and configuration, Daytona will clone the specified Git repository and set up a new Workspace based on its contents. You will see progress information in the terminal, indicating the process of creating a Workspace.
Once complete, the Workspace will be ready for use with the specified repository and configuration.
Create a Workspace with Multiple Projects
Daytona allows you to create a Workspace that contains multiple repositories, which we refer to as Projects. This enables you to work on several codebases simultaneously within a single environment.
Multiple projects are deployed within the same virtual machine or instance depending on the Provider infrastructure, allowing you to manage and develop multiple projects in a unified Workspace.
- The Docker Provider deploys each project in its own container.
- The AWS Provider deploys projects within the same EC2 instance.
- The DigitalOcean Provider deploys projects within the same Droplet.
- The Fly Provider deploys projects within the same virtual machine.
Regardless of the infrastructure type, all projects are managed consistently within the Workspace.
- Run the following command to create a Workspace with multiple projects:
- Select one of the three provided options:
-
Select from a List of Repositories
If you choose a Git provider (e.g., GitHub), you will be presented with a list of your repositories from which you can select the desired repository.
-
Enter a Custom Repository URL
Alternatively, select the option to enter a custom repository URL manually if the repository is not listed under your Git provider account or is from an external source.
-
Create from Sample
If you do not have a repository ready, choose to create a Workspace from a sample project provided by Daytona. This option allows you to set up a new development environment using quick-start templates.
- Select the Git repository from the list, enter the URL of the Git repository you want to link with your Workspace, or choose to create a Workspace from a sample project.
After your selection, you will be prompted to add a second project to the Workspace.
- Select the Git repository from the list for the second project, enter the URL of the Git repository you want to link with your Workspace, or choose to create a Workspace from a sample project.
After adding the second project, you will be prompted to add another project to the Workspace.
Selecting Yes
will allow you to add additional projects to the Workspace. Once you have added all the projects you need, select No
to complete the Workspace creation process.
After adding all projects, you will be prompted with a summary of the Workspace configuration.
- Enter a name for your Workspace.
- Select a Target to deploy your Workspace to. Selecting a Target will prompt you to input the Target configuration. The configurations vary based on the selected Target.
Upon Target selection and configuration, Daytona will clone the specified Git repository and set up a new Workspace based on its contents. You will see progress information in the terminal, indicating the process of creating a Workspace.
Once complete, the Workspace will be ready for use with the specified repository and configuration.
List Workspaces
Daytona allows you to keep track of your development environments by listing all previously created Workspaces. This helps you manage multiple projects and ensure that you can easily access and maintain your Workspaces.
- Run the following command:
Upon running this command, Daytona will display a list of your Workspaces with their details. You will be able to see the Workspace name, the repository it is connected to, the target of the Workspace, and its status.
Open An Existing Workspace
Daytona allows you to open an existing Workspace in your IDE. This enables you to quickly access and work on your projects in your preferred development environment. With Daytona, you can effortlessly switch between different Workspaces and maintain an efficient workflow.
- Run the following command:
Upon running this command, Daytona will display a list of your Workspaces with their details. You will be able to see the Workspace name, the unique identifier of the Workspace, and the repository it is connected to.
- Select the Workspace you want to open.
Delete Workspaces
Daytona allows you to delete one or more Workspaces, helping you manage your development environments by removing those that are no longer needed.
- Run the following command:
Upon running this command, Daytona will display a list of your Workspaces with their details. You will be able to see the Workspace name, the unique identifier of the Workspace, and the repository it is connected to.
-
Mark Workspaces for deletion by highlighting them and pressing
x
. -
Press
Enter
on the selected Workspace to delete it.
- Confirm the action.
Non-Interactively
Daytona allows you to delete one or more existing Workspaces non-interactively, allowing for quick and automated cleanup of your development environments without manual selection.
- Run the following command, specifying the workspace names/UUIDs to delete:
Upon running this command, Daytona will prompt you to confirm the deletion of the specified Workspace. You will be able to see the Workspace name that you are about to delete, and you will have the option to confirm or cancel the action.
- Confirm the action to delete the selected Workspace.
Forward Ports from a Workspace
Daytona supports flexible port forwarding, allowing you to access services running in a Workspace locally or via a shareable public URL. With port forwarding, you can work on your project in a Workspace and test your code externally.
Access a Port Locally
You can access services running in a Workspace on your local machine.
Prerequisite
- A running Workspace with at least one service accessible via TCP/UDP.
- Run the following command to forward a port from a running Workspace to your local machine:
Example: Allow local access to port 4321 of the example-dev-env
Workspace.
Upon running this command, Daytona will establish a port forwarding connection from the specified port in the Workspace to your local machine. The terminal will display a message indicating the local port where the forwarded connection is available:
Access a Port via Public URL
You can access services running in a Workspace via a generated public URL. This allows you to share your work with others in real-time.
Prerequisite
- A running Workspace with at least one service accessible via TCP/UDP.
- Run the following command to generate a public URL for a port on a running Workspace:
Example: Generate a URL to access port 4321 of the example-dev-env
Workspace.
Upon running this command, Daytona will first establish a local port forwarding connection and display a message indicating the local port where the forwarded connection is available.
Then, Daytona will proceed to forward the port to a public URL. The terminal will display progress information and, upon completion, provide the generated public URL.
This URL can be shared with others to provide real-time access to the service running on the specified port in your Workspace.