apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
spec:
  replicas: 2
  selector:
    matchLabels:
      app: frontend
  template:
    metadata:
      labels:
        app: frontend
    spec:
      containers:
        - name: frontend
          image: fnhsproduction.azurecr.io/frontend
          env:
            - name: AAD_B2C_CLIENT_ID
              valueFrom:
                secretKeyRef:
                  name: sessions
                  key: AAD_B2C_CLIENT_ID
            - name: AAD_B2C_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: sessions
                  key: AAD_B2C_CLIENT_SECRET
            - name: COOKIE_SECRET
              valueFrom:
                secretKeyRef:
                  name: sessions
                  key: COOKIE_SECRET
            - name: EVENTGRID_TOPIC_ENDPOINT
              valueFrom:
                secretKeyRef:
                  name: frontend
                  key: eventgrid_topic_endpoint
            - name: EVENTGRID_TOPIC_KEY
              valueFrom:
                secretKeyRef:
                  name: frontend
                  key: eventgrid_topic_key
            - name: NEXT_PUBLIC_INSTRUMENTATION_KEY
              valueFrom:
                configMapKeyRef:
                  name: telemetry
                  key: instrumentation_key
            - name: PG_URL
              valueFrom:
                secretKeyRef:
                  name: frontend
                  key: postgres_url
            - name: WORKSPACE_SERVICE_GRAPHQL_ENDPOINT
              valueFrom:
                configMapKeyRef:
                  name: frontend-cm
                  key: workspace_service_graphql_endpoint
          ports:
            - containerPort: 3000
          resources:
            limits:
              cpu: 200m
              memory: 200Mi
            requests:
              cpu: 100m
              memory: 100Mi
          readinessProbe:
            httpGet:
              path: /api/health
              port: 3000
            initialDelaySeconds: 5
            periodSeconds: 15
            timeoutSeconds: 30
          livenessProbe:
            httpGet:
              path: /api/health
              port: 3000
            initialDelaySeconds: 5
            periodSeconds: 20
            timeoutSeconds: 30
