---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: photoprism-originals-pv
  namespace: photoprism
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadOnlyMany
  hostPath:
    path: "/mnt"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: photoprism-originals-pvc
  namespace: photoprism
spec:
  accessModes:
    - ReadOnlyMany
  storageClassName: manual
  resources:
    requests:
      storage: 10Gi

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: photoprism-pvc
  namespace: photoprism
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: local-path
  resources:
    requests:
      storage: 100Gi

---
apiVersion: v1
kind: Service
metadata:
  name: photoprism-service
  namespace: photoprism
  annotations:
    metallb.universe.tf/allow-shared-ip: photoprism-share
spec:
  selector:
    app: photoprism
  ports:
    - name: http
      port: 80
      targetPort: 2342
    - name: "2342"
      port: 2342
      targetPort: 2342
  type: LoadBalancer

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: photoprism-deployment
  namespace: photoprism
spec:
  replicas: 1
  selector:
    matchLabels:
      app: photoprism
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: photoprism
    spec:
      containers:
        - name: photoprism
          image: photoprism/photoprism:latest
          env:
            - name: HOME
              value: /photoprism
            - name: PHOTOPRISM_ADMIN_PASSWORD
              value: I2tb1mdf
            - name: PHOTOPRISM_DARKTABLE_PRESETS
              value: "false"
            - name: PHOTOPRISM_DATABASE_DRIVER
              value: mysql
            - name: PHOTOPRISM_DATABASE_NAME
              value: photoprism
            - name: PHOTOPRISM_DATABASE_PASSWORD
              value: I2tb1mdf
            - name: PHOTOPRISM_DATABASE_SERVER
              value: photoprism-db-service.photoprism.svc.cluster.local:3306
            - name: PHOTOPRISM_DATABASE_USER
              value: photoprism
            - name: PHOTOPRISM_DEBUG
              value: "false"
            - name: PHOTOPRISM_DETECT_NSFW
              value: "false"
            - name: PHOTOPRISM_DISABLE_CHOWN
              value: "false"
            - name: PHOTOPRISM_DISABLE_CLASSIFICATION
              value: "false"
            - name: PHOTOPRISM_DISABLE_FACES
              value: "false"
            - name: PHOTOPRISM_DISABLE_SETTINGS
              value: "false"
            - name: PHOTOPRISM_DISABLE_TENSORFLOW
              value: "false"
            - name: PHOTOPRISM_DISABLE_WEBDAV
              value: "false"
            - name: PHOTOPRISM_EXPERIMENTAL
              value: "false"
            - name: PHOTOPRISM_HTTP_COMPRESSION
              value: gzip
            - name: PHOTOPRISM_ORIGINALS_LIMIT
              value: "5000"
            - name: PHOTOPRISM_ORIGINALS_PATH
              value: "/mnt/nfs"
            - name: PHOTOPRISM_PUBLIC
              value: "false"
            - name: PHOTOPRISM_READONLY
              value: "false"
            - name: PHOTOPRISM_SITE_AUTHOR
              value: ""
            - name: PHOTOPRISM_SITE_CAPTION
              value: Browse Your Life
            - name: PHOTOPRISM_SITE_DESCRIPTION
              value: ""
            - name: PHOTOPRISM_SITE_TITLE
              value: PhotoPrism
            - name: PHOTOPRISM_SITE_URL
              value: https://photo.dezendorf.net/
            - name: PHOTOPRISM_UPLOAD_NSFW
              value: "true"
            - name: PHOTOPRISM_WORKERS
              value: "7"
          ports:
            - containerPort: 2342
          volumeMounts:
            - mountPath: /photoprism/originals
              name: photoprism-originals-pvc
            - mountPath: /photoprism/storage
              name: photoprism-pvc
            - mountPath: /mnt/nfs/photos-family
              name: nfs-photos-mount-family
      restartPolicy: Always
      volumes:
        - name: photoprism-originals-pvc
          persistentVolumeClaim:
            claimName: photoprism-originals-pvc
        - name: photoprism-pvc
          persistentVolumeClaim:
            claimName: photoprism-pvc
        - name: nfs-photos-mount-family
          nfs:
            server: 192.168.1.87
            path: /tank/photos-family
