|
| 1 | +# Console Import from Devfile |
| 2 | + |
| 3 | +This document outlines how the console is going to use a devfile 2.0.0 spec for it's import feature targeted for Dec 4, 2020. |
| 4 | + |
| 5 | +## As-Is Today |
| 6 | + |
| 7 | +Currently the Devfile import feature is mocked with a POC [openshift/console PR](https://github.com/openshift/console/pull/6321). The POC PR, requires the build guidance devfile spec to be implemented. However, the build guidance spec is still an open discussion in the [devfile/api PR](https://github.com/devfile/api/pull/127). |
| 8 | + |
| 9 | +With an initial target date for the Dec 04, 2020; the devfile import developer preview should look similar to this [demo video](https://drive.google.com/file/d/1uLzDibVZlkMqbjtKkho04e8k2-Ns5A2W/view). |
| 10 | + |
| 11 | +The information for required to build a component from build guidances are: |
| 12 | +- Git Repo Url |
| 13 | +- Git Repo Ref |
| 14 | +- Build Context Path |
| 15 | +- Container Port |
| 16 | + |
| 17 | +The console devfile import page has the Git Repo Url, Git Repo Ref & the Build Context Path |
| 18 | + |
| 19 | +<img src="https://user-images.githubusercontent.com/31771087/99319303-4ae89180-2837-11eb-8933-eaaf41160bcd.png"> |
| 20 | + |
| 21 | +The open devfile spec for Build Guidance allows for the Dockerfile Location to be specified |
| 22 | + |
| 23 | +<img src="https://user-images.githubusercontent.com/31771087/99319306-4c19be80-2837-11eb-9639-a5c130deb4ba.png"> |
| 24 | + |
| 25 | +The Container Port in the POC was parsed from the Dockerfile's `EXPOSE` command but it should ideally be defined in the devfile. |
| 26 | + |
| 27 | +### Note: |
| 28 | +The context path is present in both the Console import form and the devfile spec. It should ideally be present only at the Console form level, since it will help find the `devfile.yaml` and as well as the `Dockerfile`. |
| 29 | + |
| 30 | +## Proposed Changes |
| 31 | + |
| 32 | +With the target deadline closing soon, we may need to provide an alternative path for the OpenShift Console to consume devfile. With the Build Guidance spec [devfile/api PR](https://github.com/devfile/api/pull/127) still an open discussion, this document proposes a solution within the boundaries of the devfile 2.0.0 spec to achieve this. |
| 33 | + |
| 34 | +Here is a proposed 2.0.0 spec devfile that can support build guidance for OpenShift Console: |
| 35 | + |
| 36 | +```yaml |
| 37 | +schemaVersion: 2.0.0 |
| 38 | +metadata: |
| 39 | + name: nodejs |
| 40 | + version: 1.0.0 |
| 41 | + attributes: |
| 42 | + build.guidance-dockerfile: https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/build/Dockerfile # can also be a path relative to the context provided in the Console devfile import form |
| 43 | +components: |
| 44 | +- name: console |
| 45 | + container: |
| 46 | + image: buildImage:latest # this is the image which will be used by the Console's buildConfig output |
| 47 | + endpoints: |
| 48 | + - name: http-3000 # define endpoints in devfile.yaml, rather than getting it from the Dockerfile |
| 49 | + targetPort: 3000 |
| 50 | + env: |
| 51 | + - name: FOO # set container env through the devfile.yaml for the container |
| 52 | + value: "bar" |
| 53 | +``` |
| 54 | +
|
| 55 | +Console's devfile import POC is using a `BuildConfig` to build the Dockerfile from the dockerfile path location. The POC PR outputs it to an `ImageStream`. However, the above devfile proposal would require an exact image name and tag to build a container from the image. The POC PR could change the `BuiidConfig` output to a docker image. OpenShift [doc](https://docs.openshift.com/container-platform/4.6/builds/managing-build-output.html) outlines how this can be achieved via a `BuildConfig` and pushes the build to a private or dockerhub registry. |
| 56 | + |
| 57 | +The devfile container component can also mention endpoints instead of parsing it from the Dockerfile's `EXPOSE` cmd like the Console's POC currently does. Furthermore, more properties can be mentioned in the devfile container component as per the spec, to customize the pod container. |
| 58 | + |
| 59 | +These devfile information would be parsed and returned by the library and thus ensuring a consistent UX across all the consumners of the devfile. |
0 commit comments