services:
  paperless-redis:
    container_name: paperless-redis
    image: docker.io/library/redis:7
    networks:
      - paperless
    restart: always
    volumes:
      - ${DOCKER_CONFIGS}/redis/data:/data

  paperless-postgres:
    container_name: paperless-postgres
    image: docker.io/library/postgres:15
    networks:
      - paperless
    restart: always
    volumes:
      - ${DOCKER_CONFIGS}/postgres/data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: paperless
      POSTGRES_USER: paperless
      POSTGRES_PASSWORD: ieta6iuGhoorooluGieceekahFeic4

  paperless:
    container_name: paperless
    image: ghcr.io/paperless-ngx/paperless-ngx:latest
    restart: always
    depends_on:
      - paperless-postgres
      - paperless-redis
      - paperless-gotenberg
      - paperless-tika
    networks:
      - paperless
      - reverse-proxy
    ports:
      - "8112:8000"
    healthcheck:
      test: ["CMD", "curl", "-fs", "-S", "--max-time", "2", "http://localhost:8000"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - ${DOCKER_CONFIGS}/data:/usr/src/paperless/data
      - ${DOCKER_CONFIGS}/data:/usr/src/paperless/media
      - /mnt/storage/Documents/Paperless/Export:/usr/src/paperless/export
      - /mnt/storage/Documents/Paperless/Input:/usr/src/paperless/consume
    env_file: .env
    environment:
      PAPERLESS_REDIS: redis://paperless-redis:6379
      PAPERLESS_DBHOST: paperless-postgres
      PAPERLESS_TIKA_ENABLED: 1
      PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://paperless-gotenberg:3000
      PAPERLESS_TIKA_ENDPOINT: http://paperless-tika:9998

  paperless-gotenberg:
    container_name: paperless-gotenberg
    image: docker.io/gotenberg/gotenberg:7.10
    networks:
      - paperless
    restart: always
    command:
      - "gotenberg"
      - "--chromium-disable-javascript=true"
      - "--chromium-allow-list=file:///tmp/.*"

  paperless-tika:
    container_name: paperless-tika
    image: ghcr.io/paperless-ngx/tika:latest
    networks:
      - paperless
    restart: always

networks:
  paperless:
    name: paperless
  reverse-proxy:
    name: reverse-proxy
    external: true
