schemaVersion: 2.1.0
metadata:
  name: nodejs-web-app
  namespace: admin-devspaces
attributes:
  dw.metadata.annotations:
    che.eclipse.org/che-editor: eclipse/che-theia/latest
    che.eclipse.org/devfile-source: |
      scm:
        repo: 'https://github.com/devspaces-samples/web-nodejs-sample.git'
        revision: che-qe-tests
        fileName: devfile.yaml
      factory:
        params: 'url=https://github.com/devspaces-samples/web-nodejs-sample/tree/che-qe-tests'
    che.eclipse.org/last-updated-timestamp: '2022-07-25T10:02:17.152Z'
projects:
  - git:
      checkoutFrom:
        revision: che-qe-tests
      remotes:
        origin: 'https://github.com/devspaces-samples/web-nodejs-sample.git'
    name: web-nodejs-sample
components:
  - attributes:
      app.kubernetes.io/name: tools
      che-theia.eclipse.org/vscode-extensions:
        - 'http://plugin-registry.openshift-devspaces.svc:8080/resources/github_com/redhat-developer/devspaces-vscode-extensions/releases/download/v069c634/vscode-xml-0.17.0.vsix'
        - 'http://plugin-registry.openshift-devspaces.svc:8080/resources/github_com/redhat-developer/devspaces-vscode-extensions/releases/download/ve96a2bb/vscode-yaml-0.14.0.vsix'
    container:
      args:
        - sh
        - '-c'
        - '${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}'
      endpoints:
        - exposure: public
          name: nodejs
          protocol: http
          targetPort: 3000
      env:
        - name: PLUGIN_REMOTE_ENDPOINT_EXECUTABLE
          value: /remote-endpoint/plugin-remote-endpoint
        - name: THEIA_PLUGINS
          value: 'local-dir:///plugins/sidecars/tools'
        - name: CHE_DASHBOARD_URL
          value: 'https://devspaces.apps.ocp410.crw-qe.com'
        - name: CHE_PLUGIN_REGISTRY_URL
          value: 'https://devspaces.apps.ocp410.crw-qe.com/plugin-registry/v3'
        - name: CHE_PLUGIN_REGISTRY_INTERNAL_URL
          value: 'http://plugin-registry.openshift-devspaces.svc:8080/v3'
      image: 'quay.io/devspaces/udi-rhel8:latest'
      memoryLimit: 1G
      mountSources: true
      sourceMapping: /projects
      volumeMounts:
        - name: npm
          path: /home/user/.npm
        - name: remote-endpoint
          path: /remote-endpoint
        - name: plugins
          path: /plugins
    name: tools
  - name: npm
    volume:
      size: 1G
commands:
  - exec:
      commandLine: npm install
      component: tools
      group:
        kind: build
      label: Download dependencies
      workingDir: '${PROJECTS_ROOT}/web-nodejs-sample/app'
    id: 1-dependencies
  - exec:
      commandLine: nodemon app.js
      component: tools
      group:
        kind: run
      label: Run the web app
      workingDir: '${PROJECTS_ROOT}/web-nodejs-sample/app'
    id: 2-run
  - exec:
      commandLine: npm install; nodemon app.js
      component: tools
      group:
        kind: run
      label: Run the web app (and download dependencies)
      workingDir: '${PROJECTS_ROOT}/web-nodejs-sample/app'
    id: 3-install-and-run
  - exec:
      commandLine: nodemon --inspect app.js
      component: tools
      group:
        isDefault: true
        kind: debug
      label: Run the web app (debugging enabled)
      workingDir: '${PROJECTS_ROOT}/web-nodejs-sample/app'
    id: 4-debug
  - exec:
      commandLine: 'node_server_pids=$(pgrep -fx ''.*nodemon (--inspect )?app.js'' | tr "\\n" " ") && echo "Stopping node server with PIDs: ${node_server_pids}" &&  kill -15 ${node_server_pids} &>/dev/null && echo ''Done.'''
      component: tools
      group:
        kind: run
      label: Stop the web app
    id: 5-stopapp
