#!/bin/bash

BUILD_ENV=$1
OP=$2
SPACK_ENV_TAR_FILE=$3
OC_JOB_ID=$4

cat <<EOT >> simplejob.yml
apiVersion: batch/v1
kind: Job
metadata:
  name: simplejob${OC_JOB_ID}
spec:
  parallelism: 1    
  completions: 1
  backoffLimit: 0    
  template:         
    metadata:
      name: testjob
    spec:
      #securityContext:
      #  supplementalGroups: [1000410000]
      #  seLinuxOptions:
      #    level: s0:c25,c10
      containers:
      - name: simplejob
        image: docker-registry.ebrains.eu/tc/ebrains-spack-build-env:latest
        securityContext:
          runAsUser: 1000410000
        volumeMounts:
          - name: sharedbin
            mountPath: /srv
        command: ["/usr/local/bin/deploy-build-env.sh", "$BUILD_ENV", "$OP", "$SPACK_ENV_TAR_FILE"]
      volumes:
        - name: sharedbin
          persistentVolumeClaim:
            claimName: shared-binaries
      restartPolicy: Never    
EOT
