apiVersion: apps/v1
kind: Deployment
metadata:
  name: sco-bot
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sco-bot
  template:
    metadata:
      labels:
        app: sco-bot
    spec:
      volumes:
        - name: sco-bot-data
          persistentVolumeClaim:
            claimName: sco-bot-data
      containers:
        - name: vite
          image: reg:5000/sco_bot_web
          workingDir: /opt
          command:
            - pnpm
            - exec
            - vite
          ports:
            - containerPort: 8002
              name: web

        - name: search-server
          image: reg:5000/sco_bot_server
          securityContext: { runAsUser: 1020 }
          workingDir: /opt
          command:
            - pdm
            - run
            - fastapi
            - dev
            - --host
            - "0.0.0.0"
            - --port
            - "8001"
            - scobot
          ports:
            - containerPort: 8001
              name: server
          volumeMounts:
          - name: sco-bot-data
            mountPath: /opt/data

        - name: prefect
          image: reg:5000/sco_bot_server
          securityContext: { runAsUser: 1020 }
          workingDir: /opt
          env:
            - name: PREFECT_API_URL
              value: https://sco-bot-prefect.bigasterisk.com/api
          command:
            - pdm
            - run_prefect_server
          ports:
            - containerPort: 4200
              name: prefect
          volumeMounts:
          - name: sco-bot-data
            mountPath: /opt/data

        - name: build-flow
          image: reg:5000/sco_bot_server
          securityContext: { runAsUser: 1020 }
          workingDir: /opt
          env:
            - name: PREFECT_API_URL
              value: http://localhost:4200/api
          command:
            - pdm
            - run_build_flow
          volumeMounts:
          - name: sco-bot-data
            mountPath: /opt/data

      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: "kubernetes.io/hostname"
                operator: In
                values: ["ditto", "dash"] # need /my/serv