apiVersion: batch/v1
kind: Job
metadata:
  name: prepare-ds
spec:
  backoffLimit: 2
  template:
    spec:
      volumes:
        - name: ds-files
          persistentVolumeClaim:
            claimName: ${PVC_NAME}
        - name: stop-scripts
          configMap:
            name: stop-ds
            defaultMode: 0755
      containers:
        - name: prepare-ds
          image: postgres
          envFrom:
          - configMapRef:
              name: documentserver
          env:
          - name: DB_PWD
            value: ${DB_PASSWORD}
          - name: PRODUCT_NAME
            value: ${PRODUCT_NAME}
          volumeMounts:
          - name: ds-files
            mountPath: /var/lib/${PRODUCT_NAME}/documentserver/App_Data/cache/files
          - name: stop-scripts
            mountPath: /sql/stop.sh
            subPath: stop.sh
          command: ["/bin/sh", "-c"]
          args: ["/sql/stop.sh"]
      restartPolicy: Never
