apiVersion: v1
kind: Service
metadata:
  name: ozone
  namespace: atproto
spec:
  selector:
    app: ozone
  ports:
    - port: 3000
      targetPort: 3000
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ozone-data
  namespace: atproto
spec:
  accessModes: ["ReadWriteOnce"]
  resources:
    requests:
      storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ozone
  namespace: atproto
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ozone
  template:
    metadata:
      labels:
        app: ozone
    spec:
      containers:
        - name: ozone
          image: registry/ozone
          command: ["node", "--enable-source-maps", "api.js"]
          ports:
            - containerPort: 3000
          env:
            - name: OZONE_SERVER_DID
              value: "did:web:ozone.syu.is"
            - name: OZONE_PUBLIC_URL
              value: "https://ozone.syu.is"
            - name: OZONE_DB_POSTGRES_URL
              value: "postgres://postgres:postgres@database/ozone"
            - name: OZONE_DID_PLC_URL
              value: "https://plc.syu.is"
            - name: OZONE_APPVIEW_DID
              value: "did:web:bsky.syu.is"
            - name: OZONE_APPVIEW_URL
              value: "https://bsky.syu.is"
            - name: OZONE_APPVIEW_PUSH_EVENTS
              value: "true"
            - name: OZONE_PDS_DID
              value: "did:web:syu.is"
            - name: OZONE_PDS_URL
              value: "https://syu.is"
            - name: OZONE_DEV_MODE
              value: "true"
            - name: OZONE_DB_MIGRATE
              value: "1"
            - name: OZONE_ADMIN_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: atproto-secrets
                  key: ozone-admin-password
            - name: OZONE_SIGNING_KEY_HEX
              valueFrom:
                secretKeyRef:
                  name: atproto-secrets
                  key: ozone-signing-key-hex
          volumeMounts:
            - name: data
              mountPath: /data
          livenessProbe:
            httpGet:
              path: /xrpc/_health
              port: 3000
            initialDelaySeconds: 10
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /xrpc/_health
              port: 3000
            initialDelaySeconds: 5
            periodSeconds: 5
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: ozone-data
