# services/nextcloud/cronjob.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: nextcloud-cron
  namespace: nextcloud
spec:
  schedule: "*/5 * * * *"
  suspend: true
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          securityContext:
            runAsUser: 33
            runAsGroup: 33
            fsGroup: 33
          restartPolicy: OnFailure
          containers:
            - name: nextcloud-cron
              image: nextcloud:29-apache
              imagePullPolicy: IfNotPresent
              command: ["/bin/sh", "-c"]
              args:
                - "cd /var/www/html && php -f cron.php"
              volumeMounts:
                - name: nextcloud-web
                  mountPath: /var/www/html
                - name: nextcloud-config-pvc
                  mountPath: /var/www/html/config
                - name: nextcloud-custom-apps
                  mountPath: /var/www/html/custom_apps
                - name: nextcloud-user-data
                  mountPath: /var/www/html/data
          volumes:
            - name: nextcloud-config-pvc
              persistentVolumeClaim:
                claimName: nextcloud-config-v2
            - name: nextcloud-custom-apps
              persistentVolumeClaim:
                claimName: nextcloud-custom-apps-v2
            - name: nextcloud-user-data
              persistentVolumeClaim:
                claimName: nextcloud-user-data-v2
            - name: nextcloud-web
              persistentVolumeClaim:
                claimName: nextcloud-web-v2
