version: "3.4"
services:
  broker:
    image: docker.io/library/redis:7
    restart: unless-stopped
    volumes:
      - redisdata:/data

  db:
    image: docker.io/library/postgres:15
    restart: unless-stopped
    volumes:
      - pgdata:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: paperless
      POSTGRES_USER: paperless
      POSTGRES_PASSWORD: paperless

  webserver:
    image: ghcr.io/paperless-ngx/paperless-ngx:latest
    restart: unless-stopped
    depends_on:
      - db
      - broker
    ports:
      - "8010:8000"  # Changed to port 8010
    volumes:
      - data:/usr/src/paperless/data
      - type: volume
        source: paperless_consume
        target: /usr/src/paperless/consume
        volume:
          nocopy: true
      - type: volume
        source: paperless_media
        target: /usr/src/paperless/media
        volume:
          nocopy: true
      - type: volume
        source: paperless_export
        target: /usr/src/paperless/export
        volume:
          nocopy: true
    environment:
      PAPERLESS_REDIS: redis://broker:6379
      PAPERLESS_DBHOST: db
      PAPERLESS_TIME_ZONE: Europe/Berlin
      PAPERLESS_OCR_LANGUAGE: deu+eng
      PAPERLESS_TASK_WORKERS: 2
      PAPERLESS_WEBSERVER_WORKERS: 2
      USERMAP_UID: 1000
      USERMAP_GID: 1000
      PAPERLESS_APPS: "allauth.socialaccount.providers.openid_connect"
      PAPERLESS_SOCIALACCOUNT_PROVIDERS: >
        {
          "openid_connect": {
            "APPS": [
              {
                "provider_id": "zitadel",
                "name": "Zitadel",
                "client_id": "325704363144187906",
                "secret": "ldKbl3A4NlnofkRKYXKZxZZPVUfpyfkRhd5kcoY0SDExYupuGzxA7624itePjShs",
                "settings": {
                  "server_url": "https://elbird.mywire.org/.well-known/openid-configuration"
                }
              }
            ]
          }
        }
      PAPERLESS_FORCE_SCRIPT_NAME: ""
      PAPERLESS_USE_X_FORWARD_HOST: "false" 
      PAPERLESS_USE_X_FORWARD_PORT: "false"
      PAPERLESS_USE_X_FORWARD_PROTO: "false"
      PAPERLESS_URL: "http://100.100.214.200:8010"
volumes:
  redisdata:
  pgdata:
  data:
  paperless_consume:
    driver: local
    driver_opts:
      type: nfs
      o: addr=192.168.2.132,rw,nfsvers=3,nolock
      device: ":/volume1/homes/paperless/consume"
  paperless_media:
    driver: local
    driver_opts:
      type: nfs
      o: addr=192.168.2.132,rw,nfsvers=3,nolock
      device: ":/volume1/homes/paperless/media"
  paperless_export:
    driver: local
    driver_opts:
      type: nfs
      o: addr=192.168.2.132,rw,nfsvers=3,nolock
      device: ":/volume1/homes/paperless/export"
