apiVersion: apps/v1
kind: Deployment
metadata:
  name: squidex
spec:
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: squidex
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: squidex
    spec:
      containers:
        - name: squidex
          image: squidex/squidex:4.5.1
          imagePullPolicy: Always
          resources:
            requests:
              memory: "512Mi"
              cpu: "250m"
            limits:
              memory: "3072Mi"
              cpu: "500m"
          readinessProbe:
            httpGet:
              path: /readiness
              port: 80
              scheme: HTTP
          livenessProbe:
            httpGet:
              path: /healthz
              port: 80
              scheme: HTTP
            initialDelaySeconds: 360
          ports:
            - containerPort: 80
          env:
            - name: ASSETS__MAXSIZE
              value: "52428800"
            - name: ASSETSTORE__TYPE
              value: "AmazonS3"
            - name: ASSETSTORE__AMAZONS3__BUCKET
              valueFrom:
                secretKeyRef:
                  name: squidex-params
                  key: S3_BUCKET
            - name: ASSETSTORE__AMAZONS3__REGIONNAME
              value: "us-east-1"
            - name: ASSETSTORE__AMAZONS3__ACCESSKEY
              valueFrom:
                secretKeyRef:
                  name: squidex
                  key: iam_access_key
            - name: ASSETSTORE__AMAZONS3__SECRETKEY
              valueFrom:
                secretKeyRef:
                  name: squidex
                  key: iam_secret_key
            - name: DD_AGENT_HOST
              valueFrom:
                fieldRef:
                  fieldPath: status.hostIP
            - name: EVENTSTORE__MONGODB__CONFIGURATION
              valueFrom:
                secretKeyRef:
                  name: squidex
                  key: mongo_connection_string
            - name: EVENTSTORE__MONGODB__DATABASE
              value: "Squidex"
            - name: EMAIL__SMTP__SERVER
              value: "email-smtp.us-east-1.amazonaws.com"
            - name: EMAIL__SMTP__SENDER
              value: "squidex@learnwithhomer.com"
            - name: EMAIL__SMTP__USERNAME
              value: AKIAYWLMFLI6YQPOC56T
            - name: EMAIL__SMTP__PASSWORD
              valueFrom:
                secretKeyRef:
                  name: squidex
                  key: email_smtp_password
            - name: EMAIL__SMTP__ENABLESSL
              value: "true"
            - name: EMAIL__SMTP__PORT
              value: "587"
            - name: HEALTHZ__GC__THRESHOLD
              value: "8192"             
            # The following can be set to create an admin user
            - name: IDENTITY__ADMINRECREATE
              value: "true"
            - name: IDENTITY__ADMINEMAIL
              valueFrom:
                secretKeyRef:
                  name: squidex-params
                  key: ADMIN_EMAIL
            - name: IDENTITY__ADMINPASSWORD
              valueFrom:
                secretKeyRef:
                  name: squidex
                  key: squidex_admin_password
            - name: IDENTITY__GOOGLECLIENT
              valueFrom:
                secretKeyRef:
                  name: squidex
                  key: google_auth_client_id
            - name: IDENTITY__GOOGLESECRET
              valueFrom:
                secretKeyRef:
                  name: squidex
                  key: google_auth_secret
            # Specifically Blanking out to deactive these options
            - name: IDENTITY__GITHUBCLIENT
              value: ""
            - name: IDENTITY__MICROSOFTCLIENT
              value: ""
            - name: LOGGING__HUMAN
              value: "false"
            - name: LOGGING__DATADOG
              value: "true"
            - name: ORLEANS__CLUSTERING
              value: "MongoDB"
            - name: STORE__MONGODB__CONFIGURATION
              valueFrom:
                secretKeyRef:
                  name: squidex
                  key: mongo_connection_string
            - name: STORE__MONGODB__DATABASE
              value: "Squidex"
            - name: STORE__MONGODB__CONTENTDATABASE
              value: "SquidexContentV2"                       
            - name: URLS__BASEURL
              valueFrom:
                secretKeyRef:
                  name: squidex-params
                  key: DOMAIN
            - name: URLS__ENFORCEHTTPS
              value: "false"            
      terminationGracePeriodSeconds: 30
