apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: ti-community-bots
  name: ti-sync-bot
  labels:
    app: ti-sync-bot
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ti-sync-bot
  template:
    metadata:
      labels:
        app: ti-sync-bot
    spec:
      containers:
        - name: ti-sync-bot
          image: miniant/ti-sync-bot:latest
          ports:
            - containerPort: 3000
              protocol: TCP
          env:
            # App Config
            - name: APP_ID
              valueFrom:
                secretKeyRef:
                  name: app-config
                  key: app_id
            - name: PRIVATE_KEY_PATH
              value: /etc/app-config/private_key.pem
            - name: WEBHOOK_SECRET
              valueFrom:
                secretKeyRef:
                  name: app-config
                  key: webhook_secret
            - name: GITHUB_ACCESS_TOKEN
              valueFrom:
                secretKeyRef:
                  name: app-config
                  key: github_token
            # Database config
            - name: BOT_DB_HOST
              valueFrom:
                secretKeyRef:
                  name: database-config
                  key: host
            - name: BOT_DB_PORT
              valueFrom:
                secretKeyRef:
                  name: database-config
                  key: port
            - name: BOT_DB_USERNAME
              valueFrom:
                secretKeyRef:
                  name: database-config
                  key: username
            - name: BOT_DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: database-config
                  key: password
            - name: BOT_DB_NAME
              valueFrom:
                secretKeyRef:
                  name: database-config
                  key: database_name
          volumeMounts:
            - name: app-config-volume
              mountPath: /etc/app-config
              readOnly: true
      volumes:
        - name: app-config-volume
          secret:
            secretName: app-config
