apiVersion: batch/v1
kind: CronJob
metadata:
  name: scheduler
  labels:
    app: scheduler
spec:
  schedule: "* * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          volumes:
          - name: cache
            emptyDir: {}
          - name: testing
            emptyDir: {}
          - name: views
            emptyDir: {}
          - name: app-storage
            emptyDir: {}
          imagePullSecrets:
          - name: docker-credentials
          securityContext:
            fsGroup: 1000
          containers:
            - name: scheduled
              image: ghcr.io/rendyananta/urlhub:${APP_VERSION}
              imagePullPolicy: Always
              resources:
                limits:
                  cpu: 100m
                  memory: 100Mi
              volumeMounts:
              - name: cache
                mountPath: /var/www/html/storage/framework/cache
              - name: views
                mountPath: /var/www/html/storage/framework/views
              - name: testing
                mountPath: /var/www/html/storage/framework/testing
              - name: app-storage
                mountPath: /var/www/html/storage/app
              envFrom:
                - configMapRef:
                    name: app
                - secretRef:
                    name: app
              command:
                - "php"
              args:
                - "artisan"
                - "schedule:run"
          restartPolicy: OnFailure
