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: eu.gcr.io/fhir-ch/matchbox:v094
          env:
            - name: spring.datasource.url
              value: jdbc:mysql://hapi-fhir-mysql-service:3306/hapi
            - name: spring.datasource.username
              value: admin
            - name: spring.datasource.password
              value: instant101
            - name: spring.datasource.driverClassName
              value: com.mysql.jdbc.Driver
            - name: spring.jpa.properties.hibernate.dialect
              value: org.hibernate.dialect.MySQL5InnoDBDialect
            - name: hapi.fhir.allow_external_references
              value: 'true'
      restartPolicy: Always
