Development Environment Management
Daytona is a development environment manager that simplifies the creation and management of complex development environments. It leverages container technologies to provide a consistent and reproducible development experience.
Workspace Management
Daytona manages workspaces, which represent individual development environments. Workspaces contain projects, which are individual codebases.
The daytona
CLI provides a comprehensive set of commands for managing workspaces:
daytona create
: Creates a new workspace.--blank
: Creates a blank project without using existing configurations.--branch
: Specifies the Git branch to use in the project.--builder
: Specifies the builder (currentlyauto
,devcontainer
, ornone
).-c, --code
: Opens the workspace in the IDE after workspace creation.--custom-image
: Creates the project with a custom image. Requires setting the--custom-image-user
flag as well.--custom-image-user
: Creates the project with a custom image user. Requires setting the--custom-image
flag as well.--devcontainer-path
: Automatically assigns thedevcontainer
builder with the path passed as the flag value.-i, --ide
: Specifies the IDE (‘vscode’ or ‘browser’).--manual
: Manually enters the Git repositories.--multi-project
: Creates a workspace with multiple projects/repos.--name
: Specifies the workspace name.--provider
: Specifies the provider (e.g.docker-provider
).-t, --target
: Specifies the target (e.g.local
).
daytona list
: Lists existing workspaces.daytona start
: Starts a workspace.-a, --all
: Starts all workspaces.-p, --project
: Starts a single project in the workspace (project name).
daytona stop
: Stops a workspace.daytona delete
: Deletes a workspace.daytona info
: Shows workspace information.
Project Configuration
Daytona supports flexible project configurations to accommodate different development needs.
daytona project-config
: Manages project configs.add
: Adds a project configuration.delete
: Deletes a project configuration.info
: Shows project configuration information.list
: Lists project configurations.set-default
: Sets a project configuration as the default.update
: Updates a project configuration.
Devcontainer Support
Daytona leverages Devcontainers for defining project-specific development environments.
DevcontainerConfig
(frompkg/apiclient/docs/DevcontainerConfig.md
): Represents a Devcontainer configuration.FilePath
: The path to the Devcontainer configuration file.
ProjectBuildConfig
(frompkg/apiclient/docs/ProjectBuildConfig.md
): Represents a project build configuration.Devcontainer
: A pointer to the Devcontainer configuration.
Other Features
Daytona includes additional features for improving developer workflows:
daytona env
: Manages environment variables that are added to all workspaces.daytona forward
: Forwards a port from a project to your local machine.daytona ssh
: SSH into a project using the terminal.daytona code
: Opens a workspace in your preferred IDE.
Code Examples
pkg/workspace/project/project.go
: This file defines theGetConfigHash
function, which calculates a hash based on a project’s configuration.// GetConfigHash returns a SHA-256 hash of the project's build configuration, repository URL, and environment variables. func (p *Project) GetConfigHash() (string, error) { buildJson, err := json.Marshal(p.BuildConfig) if err != nil { return "", err } // todo: atm env vars contain workspace env provided by the server // this causes each workspace to have a different hash // envVarsJson, err := json.Marshal(p.EnvVars) // if err != nil { // return "", err // } data := string(buildJson) + p.Repository.Sha /* + string(envVarsJson)*/ hash := sha256.Sum256([]byte(data)) hashStr := hex.EncodeToString(hash[:]) return hashStr, nil }
pkg/cmd/workspace/create.go
: Defines thedevcontainerPathFlag
variable, which is used for specifying a Devcontainer configuration path.devcontainerPathFlag
pkg/apiclient/model_project_build_config.go
: Defines methods for accessing and manipulating the Devcontainer configuration in aProjectBuildConfig
object.// GetDevcontainer returns the Devcontainer field value if set, zero value otherwise. func (o *ProjectBuildConfig) GetDevcontainer() DevcontainerConfig { if o == nil || IsNil(o.Devcontainer) { var ret DevcontainerConfig return ret } return *o.Devcontainer } // GetDevcontainerOk returns a tuple with the Devcontainer field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *ProjectBuildConfig) GetDevcontainerOk() (*DevcontainerConfig, bool) { if o == nil || IsNil(o.Devcontainer) { return nil, false } return o.Devcontainer, true }
Resources
- Daytona Repository: https://github.com/daytonaio/daytona
- Daytona Documentation: https://github.com/daytonaio/daytona
- Devcontainer Specification: https://devcontainers.dev/docs/specifications
Top-Level Directory Explanations
.devcontainer/ - Contains development container related configurations for Visual Studio Code.
hack/ - Directory for Go development, including build scripts and dependencies.
hack/project_image/ - Subdirectory for building the project Docker image.
internal/ - Private package directory for the project’s internal modules.
internal/jetbrains/ - Subdirectory for JetBrains IDE integrations.
internal/testing/ - Subdirectory for testing-related modules.
internal/testing/agent/ - Subdirectory for testing agents.
internal/testing/docker/ - Subdirectory for Docker-related testing configurations.
internal/testing/git/ - Subdirectory for Git-related testing configurations.
internal/testing/logger/ - Subdirectory for logging configurations for tests.
internal/testing/provider/ - Subdirectory for testing providers.
internal/testing/server/ - Subdirectory for testing server configurations.
pkg/ - Go packages directory.
pkg/cmd/ - Subdirectory for command-line interface tools.
pkg/cmd/profiledata/ - Subdirectory for profiledata command-line tools.
pkg/cmd/projectconfig/ - Subdirectory for project configuration command-line tools.
pkg/docker/ - Subdirectory for Docker-related packages and scripts.
pkg/server/ - Subdirectory for server-related packages and scripts.
pkg/server/projectconfig/ - Subdirectory for project configuration server-side.
pkg/server/workspaces/ - Subdirectory for workspaces server-side.
pkg/views/ - Subdirectory for view templates.