version: "3.7"

services:
  app_proxy:
    environment:
      APP_HOST: paperless_webserver_1
      APP_PORT: 8000
      PROXY_AUTH_ADD: 'false'

  broker:
    image: docker.io/library/redis:7@sha256:d6ecc832969a4827645a083da38345327b3447772fe907e7d4311c79b4e3a06e
    restart: on-failure
    volumes:
      - ${APP_DATA_DIR}/data/redisdata:/data

  db:
    image: docker.io/library/postgres:16@sha256:46aa2ee5d664b275f05d1a963b30fff60fb422b4b594d509765c42db46d48881
    restart: on-failure
    volumes:
      - ${APP_DATA_DIR}/data/pgdata:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: paperless
      POSTGRES_USER: paperless
      POSTGRES_PASSWORD: paperless

  webserver:
    image: ghcr.io/paperless-ngx/paperless-ngx:2.20.15@sha256:6c86cad803970ea782683a8e80e7403444c5bf3cf70de63b4d3c8e87500db92f
    restart: on-failure
    depends_on:
      - db
      - broker
      - gotenberg
      - tika
    volumes:
      - ${APP_DATA_DIR}/data/data:/usr/src/paperless/data
      - ${APP_DATA_DIR}/data/media:/usr/src/paperless/media
      # TODO: move these inside the paperless app data dir once DFWebOS supports navigating to it via the UI
      - ${DFWEBOS_ROOT}/data/storage/paperless/export:/usr/src/paperless/export
      - ${DFWEBOS_ROOT}/data/storage/paperless/consume:/usr/src/paperless/consume
    environment:
      PAPERLESS_REDIS: redis://paperless_broker_1:6379
      PAPERLESS_DBHOST: paperless_db_1
      PAPERLESS_TIKA_ENABLED: 1
      PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://paperless_gotenberg_1:3000
      PAPERLESS_TIKA_ENDPOINT: http://paperless_tika_1:9998
      PAPERLESS_ADMIN_USER: admin
      PAPERLESS_ADMIN_PASSWORD: $APP_PASSWORD

  gotenberg:
    image: docker.io/gotenberg/gotenberg:7.10@sha256:d03b8a04c6e6c5e568b38f57352266dee4674849b71818774025f8f48d869a9a
    restart: on-failure

    # Маршрут gotenberg chromium используется для преобразования файлов .eml. Мы не
    # хотите разрешить внешний контент, например пиксели отслеживания или даже JavaScript.
    command:
      - "gotenberg"
      - "--chromium-disable-javascript=true"
      - "--chromium-allow-list=file:///tmp/.*"

  tika:
    image: apache/tika:3.2.3.0@sha256:c0154cb95587cde64be74f35ada1a2bd7892219f3f0ac3c9dc6cab34046b3573
    restart: on-failure
