apiVersion: batch/v1
kind: Job
metadata:
  name: "storage-setup-job"
spec:
  backoffLimit: 1
  template:
    spec:
      restartPolicy: Never
      containers:
        - name: "storage-setup-job"
          image: "ubuntu:24.04"
          command:
            - bash
            - "-c"
            # make sure the directories exist and set the permissions to 2001:2001 – the UID:GID of CoCalc users operating on these files
            - "cd /nfs && mkdir -p data software && chown -R 2001:2001 data software && chmod a+rwx data software && echo 'setting up data and software done'"
            #- "sleep infinity"
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              cpu: 100m
              memory: 256Mi
          volumeMounts:
            - mountPath: /nfs
              name: root-data

          ## uncomment this to run exactly as the user of CoCalc projects and associated services
          #securityContext:
          #  runAsGroup: 2001
          #  runAsUser: 2001

      dnsPolicy: ClusterFirst
      terminationGracePeriodSeconds: 30
      volumes:
        - name: root-data
          persistentVolumeClaim:
            claimName: root-data
