apiVersion: apps/v1
kind: Deployment
metadata:
  name: hapi-fhir-server-deployment
  labels:
    package: core
spec:
  replicas: 1
  selector:
    matchLabels:
      component: hapi-fhir-server
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        component: hapi-fhir-server
    spec:
      initContainers:
        - name: check-mysql-status
          image: busybox:1.28
          command: ['sh', '-c', 'until telnet hapi-fhir-mysql-service 3306; do echo MySQL not running yet; sleep 10; done;']
      containers:
        - name: hapi-fhir-server
          image: hapiproject/hapi:v5.2.1
          env:
            - name: JAVA_OPTS
              value: "'-Dhapi.properties=/usr/local/tomcat/conf/hapi.properties'"
          volumeMounts:
            - name: core-hapi-fhir-server-volume
              mountPath: /usr/local/tomcat/conf/hapi.properties
              subPath: hapi.properties
      restartPolicy: Always
      volumes:
        - name: core-hapi-fhir-server-volume
          configMap:
            name: core-hapi-fhir-server-configmap
