apiVersion: apps/v1
kind: Deployment
metadata:
  name: convomark
spec:
  selector:
    matchLabels:
      app: convomark
  template:
    metadata:
      labels:
        app: convomark
    spec:
      containers:
      - name: backend
        image: matteojoliveau/convomark:latest
        resources:
          requests:
            memory: 128Mi
            cpu: 100m
          limits:
            memory: 300Mi
            cpu: 300m
        ports:
        - name: http
          containerPort: 3000
          protocol: TCP
        livenessProbe:
          httpGet:
            path: /ping
            port: http
        readinessProbe:
          httpGet:
            path: /ping
            port: http
        envFrom:
          - configMapRef:
              name: app-config
          - secretRef:
              name: app-secrets
          - secretRef:
              name: db-secrets
        command: ["yarn"]
        args: ["start:prod"]

      initContainers:
        - name: migrator
          image: matteojoliveau/convomark:latest
          resources:
            requests:
              memory: 128Mi
              cpu: 100m
            limits:
              memory: 300Mi
              cpu: 300m
          envFrom:
            - configMapRef:
                name: app-config
            - secretRef:
                name: app-secrets
            - secretRef:
                name: db-secrets
          command: ["yarn"]
          args: ["db:migrate"]
