Uploaded image for project: 'Red Hat OpenShift Dev Spaces (formerly CodeReady Workspaces) '
  1. Red Hat OpenShift Dev Spaces (formerly CodeReady Workspaces)
  2. CRW-2493

Conversion from devfile v2 to devfile v1 had left workspace containers without source code

XMLWordPrintable

    • False
    • False
    • Workaround Exists
    • Hide

      Add "mountSources: true" to the "tools" and "mysql" components in resulted devfile v1, e.g.:

      components:
        - mountSources: true
          endpoints:
            - name: debug
              port: 5005
            - name: 8080-tcp
              port: 8080
          memoryLimit: 3Gi
          type: dockerimage
          alias: tools
          image: 'quay.io/devfile/universal-developer-image:ubi8-d433ed6'
      
        - endpoints:
            - name: db
              port: 3306
          memoryLimit: 300Mi
          type: dockerimage
          alias: mysql
          image: 'quay.io/eclipse/che--centos--mysql-57-centos7:latest-e08ee4d43b7356607685b69bde6335e27cf20c020f345b6c6c59400183882764'
          env:
            - value: petclinic
              name: MYSQL_USER
            - value: petclinic
              name: MYSQL_PASSWORD
            - value: petclinic
              name: MYSQL_DATABASE
            - value: '$(echo ${0})\\$'
              name: PS1
          mountSources: true
      
      
      Show
      Add " mountSources: true " to the " tools " and " mysql " components in resulted devfile v1, e.g.: components: - mountSources: true endpoints: - name: debug port: 5005 - name: 8080-tcp port: 8080 memoryLimit: 3Gi type: dockerimage alias: tools image: 'quay.io/devfile/universal-developer-image:ubi8-d433ed6' - endpoints: - name: db port: 3306 memoryLimit: 300Mi type: dockerimage alias: mysql image: 'quay.io/eclipse/che--centos--mysql-57-centos7:latest-e08ee4d43b7356607685b69bde6335e27cf20c020f345b6c6c59400183882764' env: - value: petclinic name: MYSQL_USER - value: petclinic name: MYSQL_PASSWORD - value: petclinic name: MYSQL_DATABASE - value: '$(echo ${0})\\$' name: PS1 mountSources: true

      After conversion "java-spring-petclinic" devfile v2 [1] to devfile v1 there was no project source code in /projects directory of "tools" container, and build command failed:

      "prepare-datebase" command had failed because of the same reason:

      [1] https://github.com/che-samples/java-spring-petclinic/tree/devfilev2

      There is no "mountSources: true" in "tools" component in resulted devfile v1.

      devfile v1
      apiVersion: 1.0.0
      metadata:
        name: spring-petclinicj32d
      projects:
        - name: java-spring-petclinic
          source:
            location: 'https://github.com/che-samples/java-spring-petclinic.git'
            startPoint: devfilev2
            type: git
      components:
        - endpoints:
            - name: debug
              port: 5005
            - name: 8080-tcp
              port: 8080
          memoryLimit: 3Gi
          type: dockerimage
          alias: tools
          image: 'quay.io/devfile/universal-developer-image:ubi8-d433ed6'
        - endpoints:
            - name: db
              port: 3306
          memoryLimit: 300Mi
          type: dockerimage
          alias: mysql
          image: 'quay.io/eclipse/che--centos--mysql-57-centos7:latest-e08ee4d43b7356607685b69bde6335e27cf20c020f345b6c6c59400183882764'
          env:
            - value: petclinic
              name: MYSQL_USER
            - value: petclinic
              name: MYSQL_PASSWORD
            - value: petclinic
              name: MYSQL_DATABASE
            - value: '$(echo ${0})\\$'
              name: PS1
        - id: redhat/vscode-yaml/latest
          type: chePlugin
        - id: redhat/java/latest
          type: chePlugin
        - id: redhat/vscode-xml/latest
          type: chePlugin
      commands:
        - name: prepare-database
          actions:
            - workdir: '${CHE_PROJECTS_ROOT}/java-spring-petclinic'
              type: exec
              command: |
                /opt/rh/rh-mysql57/root/usr/bin/mysql -u root < ${PROJECTS_ROOT}/java-spring-petclinic/src/main/resources/db/mysql/user.sql && \
                /opt/rh/rh-mysql57/root/usr/bin/mysql -u root petclinic < ${PROJECTS_ROOT}/java-spring-petclinic/src/main/resources/db/mysql/schema.sql && \
                /opt/rh/rh-mysql57/root/usr/bin/mysql -u root petclinic < ${PROJECTS_ROOT}/java-spring-petclinic/src/main/resources/db/mysql/data.sql && \
                echo -e "\e[32mDone.\e[0m Database petclinic was configured"
              component: mysql
        - name: build
          actions:
            - workdir: '${CHE_PROJECTS_ROOT}/java-spring-petclinic'
              type: exec
              command: mvn clean install
              component: tools
        - name: run-with-hsqldb
          actions:
            - workdir: '${CHE_PROJECTS_ROOT}/java-spring-petclinic'
              type: exec
              command: java -jar target/*.jar
              component: tools
        - name: run-with-mysql
          actions:
            - workdir: '${CHE_PROJECTS_ROOT}/java-spring-petclinic'
              type: exec
              command: |
                java -jar -Dspring-boot.run.profiles=mysql \
                -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 \
                target/*.jar
              component: tools
        - name: run-debug
          actions:
            - workdir: '${CHE_PROJECTS_ROOT}/java-spring-petclinic'
              type: exec
              command: 'java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 target/*.jar'
              component: tools
      

      To compare: https://github.com/eclipse/che/blob/main/tests/e2e/files/happy-path/happy-path-workspace.yaml

      fragment of happy path devfile v1 of petclinic project
      - type: dockerimage
          alias: maven-container
          image: quay.io/eclipse/happy-path:next
          env:
            - name: MAVEN_CONFIG
              value: /home/user/.m2
          memoryLimit: 1500Mi
          endpoints:
            - name: '8080-tcp'
              port: 8080
            - name: 'debug'
              port: 5005
              attributes:
                public: 'false'
          mountSources: true
      

        1. Screenshot from 2021-11-23 00-52-15.png
          273 kB
          Dmytro Nochevnov
        2. Screenshot from 2021-11-23 00-52-50.png
          165 kB
          Dmytro Nochevnov
        3. Screenshot from 2021-11-23 12-19-18.png
          150 kB
          Dmytro Nochevnov

              fbenoit@redhat.com Florent Benoit
              dnochevn Dmytro Nochevnov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: