apiVersion: v1
kind: Service
metadata:
  labels:
    app: theia-spring-boot
  name: theia-spring-boot
spec:
  type: NodePort
  selector:
    app: theia-spring-boot
  ports:
  - name: theia
    port: 80
    targetPort: 3000
  - name: debug
    nodePort: 30031
    port: 7999
    protocol: TCP
    targetPort: 7999
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: theia-spring-boot
  name: theia-spring-boot
spec:
  replicas: 1
  selector:
   matchLabels:  
    app: theia-spring-boot
  template:
    metadata:
      labels:
        app: theia-spring-boot
    spec:
      securityContext:
         runAsUser: 0
#        fsGroup: 1000
      containers:
        - name: theia-spring-boot
          image: theia-spring-boot
          # image: theia-spring-boot:java_ls_started
          # Image pull policy `Never` is needed to pull from local Docker Daemon
          imagePullPolicy: Never
          ports:
          - containerPort: 3000
          - containerPort: 7999
            name: "debug"
          volumeMounts:
          - name: source
            mountPath: /home/project
          resources:
            requests:
              cpu: "2000m"
              memory: 1000M
      initContainers:
        - name: git-clone
          image: alpine/git
          volumeMounts:
          - name: source
            mountPath: /tmp/git
          workingDir: /tmp/git
          command: ["git",  "clone", "https://github.com/spring-projects/spring-petclinic.git"]
      volumes:
        - name: source
          emptyDir: {}
