apiVersion: apps/v1
kind: Deployment
metadata:
  name: mindforge-api
  namespace: mindforge
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mindforge-api
  template:
    metadata:
      labels:
        app: mindforge-api
    spec:
      containers:
        - name: mindforge-api
          image: git.ivanch.me/ivanch/mindforge-api:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
          env:
            - name: OPENAI_TOKEN
              valueFrom:
                secretKeyRef:
                  name: mindforge-secrets
                  key: OPENAI_TOKEN
            - name: OPENAI_API_URL
              value: https://openrouter.ai/api/v1
            - name: OPENAI_MODEL
              value: openai/gpt-5.4-mini
            - name: GITEA_REPO_URL
              valueFrom:
                secretKeyRef:
                  name: mindforge-secrets
                  key: GITEA_REPO_URL
            - name: GITEA_ACCESS_TOKEN
              valueFrom:
                secretKeyRef:
                  name: mindforge-secrets
                  key: GITEA_ACCESS_TOKEN
            - name: ConnectionStrings__MindforgeDb
              valueFrom:
                secretKeyRef:
                  name: mindforge-secrets
                  key: ConnectionStrings__MindforgeDb
          resources:
            requests:
              memory: "128Mi"
              cpu: "250m"
            limits:
              memory: "512Mi"
              cpu: "1"
---
apiVersion: v1
kind: Service
metadata:
  name: mindforge-api
  namespace: mindforge
spec:
  selector:
    app: mindforge-api
  ports:
    - port: 80
      targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: mindforge-api
  namespace: mindforge
  labels:
    app.kubernetes.io/name: mindforge-api
spec:
  ingressClassName: nginx
  rules:
    - host: "api.mindforge.haven"
      http:
        paths:
          - path: "/"
            pathType: Prefix
            backend:
              service:
                name: mindforge-api
                port:
                  number: 80
