---
# Kaniko builds images without docker
#
# Use 'kubectl create -f kaniko.yaml' to execute
# 
# NOTES:
# If this is your first kaniko, you need to add a token:
# In gogs: User->Settings->Applications
# kubectl create secret generic git-token --from-literal='GIT_TOKEN=<your-token>'
# 
# You need to add credentials to the docker registry:
# kubectl create secret docker-registry  docker-regcred \
#  --docker-server=https://index.docker.io/v1/ \
#  --docker-username=<your-username> \
#  --docker-password=<your-password>
apiVersion: batch/v1
kind: Job
metadata:
  name: kaniko-midjourney-sort-and-upload
spec:
  ttlSecondsAfterFinished: 100
  backoffLimit: 4
  template:
    spec:
      containers:
      - name: kaniko-midjourney-sort-and-upload
        image: gcr.io/kaniko-project/executor:v1.9.1 
        args:
        - "--dockerfile=./Dockerfile"
        - "--context=git://git.monkeybox.org/Containers/midjourney-sort-and-upload#refs/heads/main"
        - "--destination=fdamstra/midjourney-sort-and-upload:latest"
        env:
          - name: GIT_TOKEN
            valueFrom:
              secretKeyRef:
                name: git-token
                key: GIT_TOKEN
        volumeMounts:
        - name: docker-config
          mountPath: /kaniko/.docker/
      dnsPolicy: "None"
      dnsConfig:
        nameservers:
          - 10.42.42.239
          - 10.42.42.1
        searches:
          - default.svc.cluster.local
          - svc.cluster.local
          - cluster.local
        options:
          - name: ndots
            value: "2"
          - name: edns0
          - name: trust-ad
      restartPolicy: Never
      volumes:
      - name: docker-config
        secret:
          secretName: docker-regcred
          items:
              - key: .dockerconfigjson
                path: config.json
