Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project image builder #363

Open
vedranjukic opened this issue Apr 6, 2024 · 3 comments · May be fixed by #531
Open

Project image builder #363

vedranjukic opened this issue Apr 6, 2024 · 3 comments · May be fixed by #531
Labels
Discussion Needs consensus enhancement New feature or request

Comments

@vedranjukic
Copy link
Member

Is your feature request related to a problem? Please describe.
Atm. Daytona can only use the default base image for Project containers.

Describe the solution you'd like
If a repository contains Devcontainer (or other supported dev env config format), Daytona should (or be able to) build the base image for the Project based on the configuration. The built image should get pushed to the container registry associated with the Provider used to provision the workspace.

The goal of this Feature request is to define the scope of the Image builder component and the implementation details.

@vedranjukic vedranjukic added enhancement New feature or request Discussion Needs consensus never stale An issue that never goes stale labels Apr 6, 2024
@Tpuljak Tpuljak removed the never stale An issue that never goes stale label Apr 8, 2024
@vedranjukic
Copy link
Member Author

vedranjukic commented Apr 17, 2024

{
    "build": {
        "dockerfile": {
            "path": "./Dockerfile",
            "context": "."
        },
        //  optional
        "prebuilds": []
    }
}

Upon workspace project create - a build process will start if defined. The resulting image can be published to the remote container registry (such as Docker hub, ECR, etc.) or can be published to the local container registry that is a part of the server process.

publish build image

@vedranjukic
Copy link
Member Author

The provider should execute the image builder. That allows the infrastructure-specific build artifacts that the provider is designed for.
For example on platforms where the project container is the compute instance, the project volume must be mounted to persist the data across the project container lifecycle. The project folder must be an artifact (persistable volume) that can be reused for multiple workspace project instances.
To support this we need to define the image builder service and extend the provider interface to support the image builder.

@vedranjukic vedranjukic linked a pull request May 11, 2024 that will close this issue
2 tasks
@vedranjukic
Copy link
Member Author

After a few iterations, the build image step is done before the Provisioner is executed. The build step is under the Workspace service context. That allows the Builder to alter the Project configuration.
Altering the Project configuration is needed because additional configuration information becomes available after the build step is completed (like post create and post start commands).
Enabling the automatic detection of the development environment configuration requires the Project configuration to change after the build step as well. If the "empty" build property is defined in the Project configuration - Daytona will read it as autocomplete true. If the development environment configuration is detected, the Project configuration will be updated.

Once the Project image is built and published to a Daytona container image repository, the image name is updated in the Project configuration. Besides the image, the user property is also updated. Suppose the user name value can not be determined from the development environment configuration or the build process. In that case, it must be predefined in the Project configuration upon the Workspace creation.

Once the Project image is built for the commit sha, it will be reused on the next Project instance from the same commit sha. Later, we should improve the Builder to reuse the previous build if possible to optimize the build process and reuse the prebuilt environment.

Lastly, the Remote Builder(s) feature must be implemented to allow scaling and multi-platform builds.

With #531 completed, Daytona can create a Workspace Project based on the dev container configuration with some limitations. Docker-compose within devcontainer.json is not supported. Rebuilds of the devcontainer.json changes need to be implemented as well. Additional configuration settings, such as run arguments and additional volume mounts, must also be supported.
Other configuration formats, such as Dockerfile/Docker-compose and Nix are planned.

Comments and suggestions are welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Needs consensus enhancement New feature or request
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

2 participants