{{- if eq .Values.ONLYOFFICE_ENABLED "yes" }}
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.version: 1.35.0 (9532ceef3)
  labels:
    io.kompose.service: nextcloud-aio-onlyoffice
  name: nextcloud-aio-onlyoffice
  namespace: "{{ .Values.NAMESPACE }}"
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: nextcloud-aio-onlyoffice
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        kompose.version: 1.35.0 (9532ceef3)
      labels:
        io.kompose.service: nextcloud-aio-onlyoffice
    spec:
      initContainers:
        - name: init-volumes
          image: ghcr.io/nextcloud-releases/aio-alpine:20250408_081359
          command:
            - chmod
            - "777"
            - /nextcloud-aio-onlyoffice
          volumeMounts:
            - name: nextcloud-aio-onlyoffice
              mountPath: /nextcloud-aio-onlyoffice
      containers:
        - env:
            - name: JWT_ENABLED
              value: "true"
            - name: JWT_HEADER
              value: AuthorizationJwt
            - name: JWT_SECRET
              value: "{{ .Values.ONLYOFFICE_SECRET }}"
            - name: TZ
              value: "{{ .Values.TIMEZONE }}"
          image: ghcr.io/nextcloud-releases/aio-onlyoffice:20250408_081359
          readinessProbe:
            exec:
              command:
                - /healthcheck.sh
            failureThreshold: 9
            initialDelaySeconds: 60
            periodSeconds: 30
            timeoutSeconds: 30
          livenessProbe:
            exec:
              command:
                - /healthcheck.sh
            failureThreshold: 9
            initialDelaySeconds: 60
            periodSeconds: 30
            timeoutSeconds: 30
          name: nextcloud-aio-onlyoffice
          ports:
            - containerPort: 80
              protocol: TCP
          volumeMounts:
            - mountPath: /var/lib/onlyoffice
              name: nextcloud-aio-onlyoffice
      volumes:
        - name: nextcloud-aio-onlyoffice
          persistentVolumeClaim:
            claimName: nextcloud-aio-onlyoffice
{{- end }}
