---
apiVersion: batch/v1
kind: Job
metadata:
  name: copychaincode
spec:
  backoffLimit: 1
  template:
    metadata:
      name: copychaincode
    spec:
      restartPolicy: "Never"
      volumes:
      - name: sharedvolume
        persistentVolumeClaim:
          claimName: common-pvc
      - name: dockersocket
        hostPath:
          path: /var/run/docker.sock
      containers:
      - name: copychaincode
        image: alpine:3.7
        imagePullPolicy: Always
        command: ["sh", "-c", "ls -l /shared/artifacts/chaincode; rm -rf /shared/artifacts/chaincode/data-marketplace-chaincode/*.*;rm -rf /shared/artifacts/chaincode/data-marketplace-chaincode/*/*.* ; ls -l /shared/artifacts/chaincode; while [ ! -d /shared/artifacts/chaincode/data-marketplace-chaincode ]; do echo Waiting for artifacts to be copied; sleep 150; done; sleep 150; ls -l /shared/artifacts/chaincode; "]
        volumeMounts:
        - mountPath: /shared
          name: sharedvolume

# apiVersion: v1
# kind: Pod
# metadata:
#   name: copychaincode
# spec:
#   containers:
#   - name: copychaincode
#     image: alpine:3.7
#     imagePullPolicy: Always
#     command: ["sh", "-c", "ls -l /shared/artifacts/chaincode; rm -rf /shared/artifacts/chaincode/data-marketplace-chaincode; ls -l /shared/artifacts/chaincode; while [ ! -d /shared/artifacts/chaincode/data-marketplace-chaincode ]; do echo Waiting for artifacts to be copied; sleep 10; done; sleep 10; ls -l /shared/artifacts/chaincode; "]
#     volumeMounts:
#      - mountPath: /shared
#        name: sharedvolume