apiVersion: batch/v1
kind: Job
metadata:
  name: magento-unpack
spec:
  template:
    metadata:
      name: unpack
      labels:
        app: magento-unpack
        k8s-app: magento
    spec:
      containers:
      - name: magento-unpack
        image: kiweeteam/magento2:2.3.6-p1-1
        command: ["/bin/sh"]
        args:
        - -c
        - |
          /bin/bash <<'EOF'
          rsync -avc /var/www/html/pub/static/frontend/ /tmp/static/frontend/ --delete
          rsync -avc /var/www/html/pub/static/adminhtml/ /tmp/static/adminhtml/ --delete
          rsync -avc /var/www/html/pub/static/deployed_version.txt /tmp/static/deployed_version.txt --delete
          EOF
        volumeMounts:
        - name: static
          mountPath: /tmp/static
        imagePullPolicy: Always
      restartPolicy: OnFailure
      volumes:
      - name: static
        persistentVolumeClaim:
          claimName: static
