apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: faveo
    app.kubernetes.io/part-of: faveo
  name: faveo
  namespace: crownlabs-ticketing
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: faveo
      app.kubernetes.io/part-of: faveo
  template:
    metadata:
      name: faveo
      labels:
        app.kubernetes.io/name: faveo
        app.kubernetes.io/part-of: faveo
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - topologyKey: "kubernetes.io/hostname"
            labelSelector:
              matchExpressions:
              - key: app.kubernetes.io/name
                operator: In
                values:
                - faveo
              - key: app.kubernetes.io/part-of
                operator: In
                values:
                - faveo
      volumes:
      - name: php-configmap-volume
        configMap:
          name: faveo-php-configmap
          items:
          - key: .env
            path: .env
      initContainers:
      - name: init-faveo
        image: crownlabs/faveo:v1.11.2-crown
        command: ["/bin/sh","-c"]
        args: ["php artisan migrate --force && php artisan db:seed --force || true"]
        volumeMounts:
        - name: php-configmap-volume
          mountPath: /usr/share/nginx/.env
          subPath: .env
      containers:
      - image: crownlabs/faveo:v1.11.2-crown
        name: faveo
        ports:
        - containerPort: 80
          name: http
        resources:
          requests:
            memory: "200Mi"
            cpu: "500m"
          limits:
            memory: "512Mi"
            cpu: "1"
        volumeMounts:
        - name: php-configmap-volume
          mountPath: /usr/share/nginx/.env
          subPath: .env

