---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: tobru-ch
  name: ghost
  namespace: tobru-ch
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      component: ghost
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        component: ghost
    spec:
      containers:
        - image: docker.io/library/ghost:5.49.1-alpine
          imagePullPolicy: IfNotPresent
          name: ghost
          env:
            - name: url
              value: https://tobru.ch/
            - name: mail__transport
              value: SMTP
            - name: mail__options__service
              value: Mailgun
            - name: mail__options__host
              value: smtp.eu.mailgun.org
            - name: mail__options__auth__user
              value: ghost@www.tobru.ch
            - name: mail__options__auth__pass
              valueFrom:
                secretKeyRef:
                  name: mailgun-auth
                  key: auth_pass
            - name: mail__from
              value: "'tobru.ch Ghost Blog <ghost@www.tobru.ch>'"
            - name: database__client
              value: sqlite3
            - name: database__connection__filename
              value: /var/lib/ghost/content/data/ghost.db
          ports:
            - containerPort: 2368
              name: ghost
              protocol: TCP
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - name: data
              mountPath: /var/lib/ghost/content
              subPath: ghost
        - image: docker.io/library/caddy:2.6.4-alpine
          imagePullPolicy: IfNotPresent
          name: caddy
          ports:
            - containerPort: 8080
          volumeMounts:
            - mountPath: /etc/caddy
              name: caddyfile
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: data
        - configMap:
            defaultMode: 420
            name: caddyconfig
          name: caddyfile
