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

Support image components to use Dockerfile as component spec #1036

Open
l0rd opened this issue Feb 7, 2023 · 1 comment
Open

Support image components to use Dockerfile as component spec #1036

l0rd opened this issue Feb 7, 2023 · 1 comment
Assignees
Labels
sprint/current Is assigned to issues which are planned to work on in the current team sprint

Comments

@l0rd
Copy link
Collaborator

l0rd commented Feb 7, 2023

Requirement

If the project includes a Dockerfile, the developer should be able to use it as a DevWorkspace component.

The specification

In the 2.2.0 Devfile API image components can reference a Dockerfile and a container can use that image:

components:
  - name: devtools-image
    image:
      imageNameSelector: devtools                    # <=== was `imageName` see https://github.com/devfile/api/issues/985
      autoBuild: true
      dockerfile:
        uri: Dockerfile                              # <=== path relative to the project root
  - name: devtools-container2
    container:
      image: quay.io/devfile/devtools:ubi8-latest    # <=== matches selector and replaced when reconciling
      memoryLimit: 512Mi
      command: ['sleep', 'infinity']

Implementation proposal

Similar to project-clone, the DevWorkspace controller could start an image-build init-container to build and publish the image (the project should be cloned first to get the Dockerfile and the build context).

The image registry, name and tag are inferred by the controller and are not exposed to the user:

  • the registry should be a DWO config
  • the name should be inferred by the devfile and component name
  • the tag should be incremental

The container component image that matches the selector is replaced with the inferred image/name/tag

Additional context

Full support of the image components is out of scope. In particular the DevWorkspace controller should raise a warning and ignore an image component that has:

  • autoBuild set to false
  • the dockerfile referenced through git or the devfile registry

We should also clarify what are the scenarios for images with autobuild: false and that are not referenced by other components.

@amisevsk amisevsk self-assigned this Feb 7, 2023
@l0rd l0rd added the sprint/current Is assigned to issues which are planned to work on in the current team sprint label Feb 18, 2023
@amisevsk
Copy link
Collaborator

amisevsk commented Mar 6, 2023

I spent some time working on this and have some proof-of-concept code for building containers in workspace initContainers. However, there are a few issues/open questions:

  • [blocker] Using an init container for this purpose, as described, will not work -- at least not without complicated and potentially error-prone workarounds. To start a pod on the cluster, Kubernetes first needs to pull all images for that pod, leading to pods expecting to build their own images failing to start (need initContainer to build image -> need image to start initContainer)
  • We could potentially instead use a job (or separate pod) to perform the container build, but then it becomes unclear when this job should be restarted and how cloning should happen (do we re-do the build every time the workspace stops + is started? How do we track this in the operator, which is stateless?)
  • Including images to build can lead to significant delays in starting a workspace, with a container build generally taking around a minute for a moderately complex container (potentially more or less, depending on what the container is doing)
    • This could potentially be worked around by allocating PVC storage to cache layers between runs; I haven't investigated this very far but this could speed up re-builds at the cost of requiring storage and managing its cleanup (when do we clear old layers from this PVC?)
  • Enabling automatic container build + push is complicated and requires a significant amount of additional configuration:
    • There needs to be some way to share image repository credential information with the builder pod (in my testing, I use a quay.io robot account and authfile mounted into the builder container)
    • The operator needs to have configuration for a repository it can push to, and the credentials provided above need to allow read/write access to that repository.

In addition to the above, we should consider other approaches to building containers -- for example, OpenShift provides BuildConfigs and ImageStreams that could potentially be used to achieve the same goal (with fewer or different drawbacks).

@l0rd l0rd moved this from 📅 Planned to 🚧 In Progress in Eclipse Che Team B Backlog Mar 27, 2023
@l0rd l0rd moved this from 🚧 In Progress to 📅 Planned in Eclipse Che Team B Backlog Jul 12, 2023
@l0rd l0rd moved this from 📅 Planned to 📋 Backlog in Eclipse Che Team B Backlog Jul 12, 2023
@RomanNikitenko RomanNikitenko moved this from 📋 Backlog to 📅 Planned in Eclipse Che Team B Backlog Jul 26, 2023
@l0rd l0rd moved this from 📅 Planned to 📋 Backlog in Eclipse Che Team B Backlog Sep 6, 2023
@ibuziuk ibuziuk assigned AObuchow and unassigned amisevsk Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sprint/current Is assigned to issues which are planned to work on in the current team sprint
Projects
None yet
Development

No branches or pull requests

3 participants