Support image components to use Dockerfile as component spec
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:
autoBuildset tofalse- the
dockerfilereferenced throughgitor thedevfile registry
We should also clarify what are the scenarios for images with autobuild: false and that are not referenced by other components.