---
apiVersion: 1.0.0
metadata:
  name: petclinic-dev-environment
projects:
  - name: petclinic
    source:
      type: git
      location: "https://github.com/spring-projects/spring-petclinic.git"
components:
  - type: cheEditor
    alias: che-theia
    reference: https://raw.githubusercontent.com/chepullreq4/pr-check-files/master/che-theia/pr-1080/che_theia_meta.yaml
    memoryLimit: 512Mi
  - type: kubernetes
    alias: petclinic-web
    reference: https://raw.githubusercontent.com/eclipse/che/master/tests/e2e/files/happy-path/containers-happy-path.yaml
    selector:
      app.kubernetes.io/component: webapp
    entrypoints:
      - containerName: spring-boot
        command: ["tail"]
        args: ["-f", "/dev/null"]
  - type: kubernetes
    alias: petclinic-db
    reference: https://raw.githubusercontent.com/eclipse/che/master/tests/e2e/files/happy-path/containers-happy-path.yaml
    selector:
      app.kubernetes.io/component: database
  - type: dockerimage
    alias: maven-container
    image: quay.io/eclipse/happy-path:nightly
    env:
      - name: MAVEN_CONFIG
        value: /home/user/.m2
    memoryLimit: 1500Mi
    mountSources: true
  - type: chePlugin
    id: redhat/java/latest
    memoryLimit: "1000Mi"
    preferences:
      java.server.launchMode: Standard
  - type: chePlugin
    id: redhat/vscode-yaml/latest
commands:
  - name: build
    actions:
      - type: exec
        component: maven-container
        command: mvn clean package | tee /workspace_logs/build.log && tail -n 40 /workspace_logs/build.log | grep 'BUILD SUCCESS' > /projects/petclinic/result-build.txt
        workdir: /projects/petclinic
  - name: build-file-output
    actions:
      - type: exec
        component: maven-container
        command: cd /projects/petclinic && mvn package | tee /workspace_logs/build-output.log && tail -n 40 /workspace_logs/build-output.log | grep 'BUILD SUCCESS' > /projects/petclinic/result-build-output.txt
  - name: run
    actions:
      - type: exec
        component: maven-container
        command: java -jar spring-petclinic-2.4.2.jar --spring.profiles.active=mysql | tee /workspace_logs/run.log
        workdir: /projects/petclinic/target
  - name: run-with-changes
    actions:
      - type: exec
        component: maven-container
        command: java -jar spring-petclinic-2.4.2.jar --spring.profiles.active=mysql | tee /workspace_logs/run-with-changes.log
        workdir: /projects/petclinic/target
  - name: run-debug
    actions:
      - type: exec
        component: maven-container
        command: java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 spring-petclinic-2.4.2.jar --spring.profiles.active=mysql | tee /workspace_logs/run-debug.log
        workdir: /projects/petclinic/target
  - name: Debug remote java application
    actions:
      - type: vscode-launch
        referenceContent: |
          {
          "version": "0.2.0",
          "configurations": [
            {
              "type": "java",
              "name": "Debug (Attach) - Remote",
              "request": "attach",
              "hostName": "localhost",
              "port": 5005
            }]
          }