apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspaceTemplate
metadata:
  name: che-theia-php-hello-world
spec:
  commands:
    - id: init-container-command
      apply:
        component: remote-runtime-injector
  events:
    preStart:
      - init-container-command
  components:
    - name: theia-ide
      container:
        image: registry.redhat.io/devspaces/theia-rhel8:3.5
        env:
          - name: THEIA_PLUGINS
            value: local-dir:///plugins
          - name: HOSTED_PLUGIN_HOSTNAME
            value: 0.0.0.0
          - name: HOSTED_PLUGIN_PORT
            value: '3130'
          - name: THEIA_HOST
            value: 127.0.0.1
        volumeMounts:
          - name: plugins
            path: /plugins
          - name: theia-local
            path: /home/theia/.theia
        mountSources: true
        memoryLimit: 512M
        cpuLimit: 1500m
        cpuRequest: 100m
        endpoints:
          - name: theia
            attributes:
              type: main
              cookiesAuthEnabled: true
              discoverable: false
              urlRewriteSupported: true
            targetPort: 3100
            exposure: public
            secure: false
            protocol: https
          - name: webviews
            attributes:
              type: webview
              cookiesAuthEnabled: true
              discoverable: false
              unique: true
              urlRewriteSupported: true
            targetPort: 3100
            exposure: public
            secure: false
            protocol: https
          - name: mini-browser
            attributes:
              type: mini-browser
              cookiesAuthEnabled: true
              discoverable: false
              unique: true
              urlRewriteSupported: true
            targetPort: 3100
            exposure: public
            secure: false
            protocol: https
          - name: theia-dev
            attributes:
              type: ide-dev
              discoverable: false
              urlRewriteSupported: true
            targetPort: 3130
            exposure: public
            protocol: http
          - name: theia-redirect-1
            attributes:
              discoverable: false
              urlRewriteSupported: false
            targetPort: 13131
            exposure: public
            protocol: http
          - name: theia-redirect-2
            attributes:
              discoverable: false
              urlRewriteSupported: false
            targetPort: 13132
            exposure: public
            protocol: http
          - name: theia-redirect-3
            attributes:
              discoverable: false
              urlRewriteSupported: false
            targetPort: 13133
            exposure: public
            protocol: http
          - name: terminal
            attributes:
              type: collocated-terminal
              discoverable: false
              cookiesAuthEnabled: true
              urlRewriteSupported: true
            targetPort: 3333
            exposure: public
            secure: false
            protocol: wss
      attributes: {}
    - name: plugins
      volume: {}
    - name: theia-local
      volume: {}
    - name: theia-ide-contributions
      container:
        image: registry.redhat.io/devspaces/udi-rhel8:3.5
        args:
          - sh
          - '-c'
          - ${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}
        env:
          - name: PLUGIN_REMOTE_ENDPOINT_EXECUTABLE
            value: /remote-endpoint/plugin-remote-endpoint
          - name: THEIA_PLUGINS
            value: local-dir:///plugins/sidecars/tools
        volumeMounts:
          - name: plugins
            path: /plugins
          - name: remote-endpoint
            path: /remote-endpoint
        memoryLimit: 512Mi
      attributes:
        controller.devfile.io/container-contribution: true
    - name: remote-endpoint
      volume:
        ephemeral: true
    - name: che-machine-exec
      container:
        image: registry.redhat.io/devspaces/machineexec-rhel8:3.5
        command:
          - /go/bin/che-machine-exec
          - '--url'
          - 127.0.0.1:3333
        memoryLimit: 128Mi
        memoryRequest: 32Mi
        cpuLimit: 500m
        cpuRequest: 30m
      attributes: {}
    - name: remote-runtime-injector
      container:
        image: registry.redhat.io/devspaces/theia-endpoint-rhel8:3.5
        env:
          - name: PLUGIN_REMOTE_ENDPOINT_EXECUTABLE
            value: /remote-endpoint/plugin-remote-endpoint
          - name: REMOTE_ENDPOINT_VOLUME_NAME
            value: remote-endpoint
        volumeMounts:
          - name: plugins
            path: /plugins
          - name: remote-endpoint
            path: /remote-endpoint
        memoryLimit: 128Mi
        memoryRequest: 32Mi
        cpuLimit: 500m
        cpuRequest: 30m
---
apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspace
metadata:
  name: php-hello-world
spec:
  started: true
  template:
    components:
      - name: tools
        container:
          image: registry.redhat.io/devspaces/udi-rhel8:3.5
          memoryLimit: 1Gi
        attributes:
          controller.devfile.io/merge-contribution: true
    commands:
      - id: run
        exec:
          label: Run the application
          component: tools
          workingDir: ${PROJECTS_ROOT}/php-hello-world
          commandLine: php hello-world.php
          group:
            kind: run
    projects:
      - name: php-hello-world
        zip:
          location: '{{ INTERNAL_URL }}/resources/v2/php-hello-world.zip'
  contributions:
    - name: editor
      kubernetes:
        name: che-theia-php-hello-world
