apiVersion: batch/v1
kind: Job
metadata:
  name: couchdb-init
spec:
  template:
    spec:
      restartPolicy: OnFailure
      initContainers:
      - image: gcr.io/alice-larp/magellan-models
        imagePullPolicy: Always
        name: magellan-models
        command:
          - cp
          - -r
          - /app/.
          - /app_destination
        volumeMounts:
        - name: models-src
          mountPath: /app_destination
      containers:
      - image: alexeyeremin/deus-couchdb-init
        imagePullPolicy: Always
        name: deus-couchdb-init
        env:
        - name: COUCHDB_USER
          valueFrom:
            secretKeyRef:
              name: couchdb-secret
              key: username
        - name: COUCHDB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: couchdb-secret
              key: password
        volumeMounts:
        - name: models-src
          mountPath: /deus-models
          readOnly: true
      volumes:
      - name: models-src
        emptyDir: {}
