---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: neon-vortex-build
  namespace: flux-system
spec:
  interval: 1m
  path: ./
  prune: false
  sourceRef:
    kind: GitRepository
    name: neon-vortex
    namespace: flux-system
  targetNamespace: default
  patches:
    - patch: |
        apiVersion: batch/v1
        kind: Job
        metadata:
          name: neon-vortex-build
          namespace: default
        spec:
          template:
            metadata:
              annotations:
                git-commit: "${GIT_COMMIT:-unknown}"
            spec:
              initContainers:
              - name: git-clone
                env:
                - name: GIT_COMMIT
                  value: "${GIT_COMMIT:-main}"
              containers:
              - name: kaniko
                args:
                - "--dockerfile=/workspace/htlm/Dockerfile"
                - "--context=/workspace/htlm"
                - "--destination=images.caffeinetux.com/apps/neon-vortex:latest"
                - "--destination=images.caffeinetux.com/apps/neon-vortex:${GIT_COMMIT:-latest}"
                - "--cache=true"
                - "--cache-repo=images.caffeinetux.com/apps/neon-vortex/cache"
      target:
        kind: Job
        name: neon-vortex-build
  postBuild:
    substituteFrom:
      - kind: ConfigMap
        name: git-commit-info
        optional: true
  healthChecks:
    - apiVersion: batch/v1
      kind: Job
      name: neon-vortex-build
      namespace: default
