apiVersion: apps/v1
kind: Deployment
metadata:
  name: $K8S_APP_NAME
spec:
  replicas: 1
  selector:
    matchLabels:
      app: $K8S_APP_NAME
  template:
    metadata:
      labels:
        app: $K8S_APP_NAME
    spec:
      containers:
        - name: app
          image: okteto.dev/fork-cms-module-commerce-demo:latest
          resources:
            limits:
              memory: 512Mi
              cpu: 700m
            requests:
              memory: 512Mi
              cpu: 500m
          ports:
            - containerPort: 80
              protocol: TCP
            - containerPort: 443
              protocol: TCP
          env:
            - name: DB_HOST
              value: 127.0.0.1
            - name: DB_NAME
              value: forkcms
            - name: DB_USER
              value: forkcms
            - name: DB_PASSWORD
              value: forkcms
            - name: SITE_DOMAIN
              value: $SITE_DOMAIN
            - name: FORK_DEBUG
              value: "1"
            - name: SMTP_USERNAME
              value: $SMTP_USERNAME # See GitHub secrets
            - name: SMTP_PASSWORD
              value: $SMTP_PASSWORD # See GitHub secrets
          # Container loads fixtures and prepares Fork CMS, we don't want to serve traffic until that finished
          readinessProbe:
            initialDelaySeconds: 90 # Wait 90s before first probe because of docker-entrypoint scripts
            periodSeconds: 30 # Check every 30s
            tcpSocket:
              port: 80

        - name: db
          image: mariadb:10
          resources:
            limits:
              memory: 128Mi
              cpu: 250m
            requests:
              memory: 128Mi
              cpu: 250m
          env:
            - name: MYSQL_DATABASE
              value: forkcms
            - name: MYSQL_ROOT_PASSWORD
              value: kingtriton
            - name: MYSQL_USER
              value: forkcms
            - name: MYSQL_PASSWORD
              value: forkcms
