apiVersion: batch/v1
kind: Job
metadata:
  name: migration
spec:
  template:
    metadata:
      name: migration
      labels:
        app: migration
    spec:
      imagePullSecrets:
        - name: docker-credentials
      volumes:
        - name: cache
          emptyDir: {}
        - name: testing
          emptyDir: {}
        - name: views
          emptyDir: {}
        - name: app-storage
          emptyDir: {}
      securityContext:
        fsGroup: 1000
      containers:
      - name: migrations
        image: ghcr.io/rendyananta/urlhub:${APP_VERSION}
        imagePullPolicy: Always
        resources:
          limits:
            cpu: 100m
            memory: 100Mi
        envFrom:
          - configMapRef:
              name: app
          - secretRef:
              name: app
        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
        command:
          - "php"
        args:
          - "artisan"
          - "migrate"
          - "--force"
      restartPolicy: OnFailure
