apiVersion: freeleaps.com/v1alpha1
kind: GitOpsInitializerConfig
metadata:
  name: magicleaps
  environment: alpha
spec:
  argo:
    name: magicleaps-alpha
    project: magicleaps
    namespace: magicleaps-alpha
    branch: develop
    syncPolicy:
      automated: true
      prune: true
      selfHeal: true
  repo:
    exists: false
    name: magicleaps
    url: https://freeleaps@dev.azure.com/freeleaps/magicleaps/_git/magicleaps
    type: monorepo
    credentials:
      username: zhenyus
      password: zhenyus
    hookRegister:
      enabled: true
      repo-provider: azure-devops # only azure devops supported for now
      events:
        - event: code-pushed
          config:
            triggerGroups: any
        - event: pr-attempted
          config:
            triggerGroups: any
            reviewersIncludesGroup: any
  ci:
    executeMode: on-demand
    commitMessageLintEnabled: true
    components:
      - name: frontend
        root: frontend
        language: javascript
        semanticReleaseEnabled: true
        dependenciesManager: npm
        npmPackageJsonFile: package.json
        buildCacheEnabled: true
        buildCommand: npm run build
        buildAgentImage: "node:lts"
        buildArtifacts:
          - dist
        lintEnabled: false
        imageBuilder:
          type: dind
          registry:
            url: docker.io
            credentials:
              username: sunzhenyucn
              password: "]wRJ**YEZp8nFq=E8WowMADf"
          repository: sunzhenyucn
          name: magicleaps-frontend
          dockerfile: Dockerfile
          buildContextRoot: "."
          releaseArchitectures:
            - linux/amd64
            - linux/arm64
      - name: backend
        root: backend
        language: python
        semanticReleaseEnabled: true
        dependenciesManager: pip
        buildCacheEnabled: true
        buildAgentImage: "python:3.8-slim-buster"
        lintEnabled: false
        imageBuilder:
          type: dint
          registry:
            url: docker.io
            credentials:
              username: sunzhenyucn
              password: "]wRJ**YEZp8nFq=E8WowMADf"
          repository: sunzhenyucn
          name: magicleaps-backend
          dockerfile: Dockerfile
          buildContextRoot: "."
          releaseArchitectures:
            - linux/amd64
            - linux/arm64
  helm:
    generate: true
    metadata:
      name: magicleaps
      description: A Helm chart for Magic Leaps application.
    global:
      registry: docker.io
      repository: magicleaps
      nodeSelector:
        beta.kubernetes.io/os: linux
      affinity: {}
    components:
      - name: frontend
        replica: 1
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 200m
            memory: 256Mi
        image:
          registry: docker.io
          repository: magicleaps-frontend
          tag: "1.0.0"
          imagePullPolicy: IfNotPresent
        probes:
          liveness:
            type: httpGet
            config:
              path: /
              port: 80
          readiness:
            type: httpGet
            config:
              path: /
              port: 80
        services:
          - name: frontend
            type: ClusterIP
            port: 80
            targetPort: 80
        ingresses:
          - name: frontend
            class: nginx
            host: alpha.magicleaps.mathmast.com
            rules:
              - path: /
                pathType: Prefix
                backend:
                  service:
                    name: frontend
                    port:
                      number: 80
            tls:
              exists: false
              secretRef:
                name: alpha.magicleaps.mathmast.com-cert
              issuerRef:
                name: mathmast-dot-com
                kind: ClusterIssuer
              name: alpha.magicleaps.mathmast.com-cert
        configs:
          - name: frontend-env
            type: environment-secret
            data:
              - key: TZ
                value: America/Los_Angeles
      - name: backend
        replica: 1
        resources:
          requests:
            cpu: 100m
            memory: 256Mi
          limits:
            cpu: 200m
            memory: 512Mi
        image:
          registry: docker.io
          repository: magicleaps-backend
          tag: "1.0.0"
          imagePullPolicy: IfNotPresent
        probes:
          liveness:
            type: httpGet
            config:
              path: /api/_/probe/liveness
              port: 8081
          readiness:
            type: httpGet
            config:
              path: /api/_/probe/readiness
              port: 8081
        services:
          - name: backend
            type: ClusterIP
            port: 8081
            targetPort: 8081
        ingresses:
          - name: backend
            class: nginx
            host: alpha.api.magicleaps.com
            tls:
              exists: false
              secretRef:
                name: alpha.api.magicleaps.mathmast.com-cert
                key: tls.crt
              issuerRef:
                name: mathmast-dot-com
                kind: ClusterIssuer
              name: alpha.api.magicleaps.mathmast.com-cert
        configs:
          - name: backend-env
            type: environment-secret
            data:
              - key: TZ
                value: America/Los_Angeles
              - key: MONGO_HOST
                value: mongo-mongodb.magicleaps-alpha.svc.cluster.local
              - key: MONGO_PORT
                value: "27017"
              - key: EMAIL_USER
                value: your@freeleaps.com
              - key: EMAIL_PASSWORD
                value: your-password
              - key: SUPER_ADMIN
                value: your@freeleaps.com
              - key: TWILIO_ACCOUNT_SID
                value: ""
              - key: TWILIO_AUTH_TOKEN
                value: ""
              - key: LOG_LEVEL
                value: INFO
