Prebuild System

Daytona uses a prebuild system to speed up environment setup for its users. It provides a way to create and manage development environments, allowing users to start working on projects quickly.

The prebuild system is based on the concept of workspaces, which are self-contained environments that include all the necessary tools and dependencies for a specific project. Workspaces can be created either manually or automatically using the daytona create command.

daytona create command

The daytona create command is used to create a new workspace. It accepts several flags to customize the workspace creation process:

  • --blank: Creates a blank project without using existing configurations.
  • --branch string: Specifies the Git branch to use in the project.
  • --builder BuildChoice: Specifies the builder (currently auto/devcontainer/none).
  • -c, --code: Opens the workspace in the IDE after workspace creation.
  • --custom-image string: Creates the project with the custom image passed as the flag value; Requires setting --custom-image-user flag as well.
  • --custom-image-user string: Creates the project with the custom image user passed as the flag value; Requires setting --custom-image flag as well.
  • --devcontainer-path string: Automatically assigns the devcontainer builder with the path passed as the flag value.
  • -i, --ide string: Specifies the IDE (‘vscode’ or ‘browser’).
  • --manual: Manually enter the Git repositories.
  • --multi-project: Workspace with multiple projects/repos.
  • --name string: Specifies the workspace name.
  • --provider string: Specifies the provider (e.g., ‘docker-provider’).
  • -t, --target string: Specifies the target (e.g., ‘local’).

Example:

daytona create --name my-project --provider docker-provider --target local --ide vscode github.com/daytonaio/daytona
          

This command creates a new workspace called “my-project” using the “docker-provider” on the “local” target. It will open the workspace in VS Code after creation.

Project Configuration

The prebuild system uses a project configuration file to define the dependencies and settings for a workspace. The project configuration is stored in a file called daytona.yaml in the root of the workspace. The configuration file defines the following properties:

  • BuildConfig: This property contains the build configuration for the project, including the builder type, image, and other settings.
  • Default: This property specifies whether the project is the default project in the workspace.
  • EnvVars: This property defines environment variables that are available to the project.
  • Image: This property specifies the Docker image to use for the project.
  • Name: This property specifies the name of the project.
  • Repository: This property specifies the Git repository for the project.
  • User: This property specifies the user to use for the project.

Example of daytona.yaml:

build_config:
            builder: auto
            image: daytonaio/daytona
            user: root
          name: my-project
          repository: github.com/daytonaio/daytona
          env_vars:
            DEBUG: true
          

Building the Project

Once the project configuration is created, the prebuild system uses it to build the project. The build process involves installing the necessary dependencies and configuring the environment. The prebuild system supports several different builders, including:

  • Devcontainer Builder: The Devcontainer builder uses a devcontainer.json file to define the environment for the project.
  • Auto Builder: The Auto builder automatically detects the builder to use based on the project type.

Running the Project

After the project is built, it can be run using the daytona start command. This command starts the project in the workspace, making it accessible through the IDE or the terminal.

Managing Workspaces

Daytona provides several commands to manage workspaces, including:

  • daytona list: Lists all workspaces.
  • daytona delete: Deletes a workspace.
  • daytona start: Starts a workspace.
  • daytona stop: Stops a workspace.

Conclusion

The prebuild system is a powerful tool for managing development environments. It provides a way to quickly and easily create, build, and run projects, reducing the time it takes to set up a new development environment.

Source:


          ## Top-Level Directory Explanations
          
          <a class='local-link directory-link' data-ref=".devcontainer/" href="#.devcontainer/">.devcontainer/</a> - Contains development container related configurations for Visual Studio Code.
          
          <a class='local-link directory-link' data-ref="cmd/" href="#cmd/">cmd/</a> - Contains command-line interface tools and scripts.
          
          <a class='local-link directory-link' data-ref="cmd/daytona/" href="#cmd/daytona/">cmd/daytona/</a> - Subdirectory for Daytona-specific command-line tools.
          
          <a class='local-link directory-link' data-ref="cmd/daytona/config/" href="#cmd/daytona/config/">cmd/daytona/config/</a> - Subdirectory for configuration files for Daytona command-line tools.
          
          <a class='local-link directory-link' data-ref="hack/" href="#hack/">hack/</a> - Directory for Go development, including build scripts and dependencies.
          
          <a class='local-link directory-link' data-ref="hack/builder_image/" href="#hack/builder_image/">hack/builder_image/</a> - Subdirectory for building Docker images for Go development.
          
          <a class='local-link directory-link' data-ref="hack/project_image/" href="#hack/project_image/">hack/project_image/</a> - Subdirectory for building the project Docker image.
          
          <a class='local-link directory-link' data-ref="internal/" href="#internal/">internal/</a> - Private package directory for the project's internal modules.
          
          <a class='local-link directory-link' data-ref="pkg/" href="#pkg/">pkg/</a> - Go packages directory.
          
          <a class='local-link directory-link' data-ref="pkg/agent/" href="#pkg/agent/">pkg/agent/</a> - Subdirectory for the project's agent package.
          
          <a class='local-link directory-link' data-ref="pkg/api/" href="#pkg/api/">pkg/api/</a> - Subdirectory for API-related packages.
          
          <a class='local-link directory-link' data-ref="pkg/api/controllers/" href="#pkg/api/controllers/">pkg/api/controllers/</a> - Subdirectory for API controller handlers.
          
          <a class='local-link directory-link' data-ref="pkg/cmd/" href="#pkg/cmd/">pkg/cmd/</a> - Subdirectory for command-line interface tools.
          
          <a class='local-link directory-link' data-ref="pkg/cmd/containerregistry/" href="#pkg/cmd/containerregistry/">pkg/cmd/containerregistry/</a> - Subdirectory for container registry command-line tools.
          
          <a class='local-link directory-link' data-ref="pkg/cmd/output/" href="#pkg/cmd/output/">pkg/cmd/output/</a> - Subdirectory for output command-line tools.
          
          <a class='local-link directory-link' data-ref="pkg/cmd/profile/" href="#pkg/cmd/profile/">pkg/cmd/profile/</a> - Subdirectory for profile command-line tools.
          
          <a class='local-link directory-link' data-ref="pkg/cmd/projectconfig/" href="#pkg/cmd/projectconfig/">pkg/cmd/projectconfig/</a> - Subdirectory for project configuration command-line tools.
          
          <a class='local-link directory-link' data-ref="pkg/cmd/server/" href="#pkg/cmd/server/">pkg/cmd/server/</a> - Subdirectory for server command-line tools.
          
          <a class='local-link directory-link' data-ref="pkg/cmd/target/" href="#pkg/cmd/target/">pkg/cmd/target/</a> - Subdirectory for target command-line tools.
          
          <a class='local-link directory-link' data-ref="pkg/cmd/workspace/" href="#pkg/cmd/workspace/">pkg/cmd/workspace/</a> - Subdirectory for workspace command-line tools.
          
          <a class='local-link directory-link' data-ref="pkg/common/" href="#pkg/common/">pkg/common/</a> - Subdirectory for common packages and utilities.
          
          <a class='local-link directory-link' data-ref="pkg/containerregistry/" href="#pkg/containerregistry/">pkg/containerregistry/</a> - Subdirectory for container registry package.
          
          <a class='local-link directory-link' data-ref="pkg/db/" href="#pkg/db/">pkg/db/</a> - Subdirectory for database-related packages and scripts.
          
          <a class='local-link directory-link' data-ref="pkg/db/dto/" href="#pkg/db/dto/">pkg/db/dto/</a> - Subdirectory for database data transfer objects.
          
          <a class='local-link directory-link' data-ref="pkg/docker/" href="#pkg/docker/">pkg/docker/</a> - Subdirectory for Docker-related packages and scripts.
          
          <a class='local-link directory-link' data-ref="pkg/frpc/" href="#pkg/frpc/">pkg/frpc/</a> - Subdirectory for Fanout Reverse Proxy (frpc) package.
          
          <a class='local-link directory-link' data-ref="pkg/git/" href="#pkg/git/">pkg/git/</a> - Subdirectory for Git-related packages and scripts.
          
          <a class='local-link directory-link' data-ref="pkg/gitprovider/" href="#pkg/gitprovider/">pkg/gitprovider/</a> - Subdirectory for Git provider package.
          
          <a class='local-link directory-link' data-ref="pkg/ide/" href="#pkg/ide/">pkg/ide/</a> - Subdirectory for IDE-related packages and scripts.
          
          <a class='local-link directory-link' data-ref="pkg/os/" href="#pkg/os/">pkg/os/</a> - Subdirectory for operating system-related packages and scripts.
          
          <a class='local-link directory-link' data-ref="pkg/ports/" href="#pkg/ports/">pkg/ports/</a> - Subdirectory for port-related packages and scripts.
          
          <a class='local-link directory-link' data-ref="pkg/posthogservice/" href="#pkg/posthogservice/">pkg/posthogservice/</a> - Subdirectory for PostHog service package.
          
          <a class='local-link directory-link' data-ref="pkg/provisioner/" href="#pkg/provisioner/">pkg/provisioner/</a> - Subdirectory for provisioner packages and scripts.
          
          <a class='local-link directory-link' data-ref="pkg/server/" href="#pkg/server/">pkg/server/</a> - Subdirectory for server-related packages and scripts.
          
          <a class='local-link directory-link' data-ref="pkg/server/containerregistries/" href="#pkg/server/containerregistries/">pkg/server/containerregistries/</a> - Subdirectory for container registries server-side.
          
          <a class='local-link directory-link' data-ref="pkg/server/headscale/" href="#pkg/server/headscale/">pkg/server/headscale/</a> - Subdirectory for Headscale server-side.
          
          <a class='local-link directory-link' data-ref="pkg/server/registry/" href="#pkg/server/registry/">pkg/server/registry/</a> - Subdirectory for registry server-side.
          
          <a class='local-link directory-link' data-ref="pkg/tailscale/" href="#pkg/tailscale/">pkg/tailscale/</a> - Subdirectory for Tailscale package.
          
          <a class='local-link directory-link' data-ref="pkg/telemetry/" href="#pkg/telemetry/">pkg/telemetry/</a> - Subdirectory for telemetry-related packages and scripts.
          
          <a class='local-link directory-link' data-ref="pkg/views/" href="#pkg/views/">pkg/views/</a> - Subdirectory for view templates.