services:
  collaboration_tenant1:
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "5"
    image: ${DOCKER_REGISTRY}/collaboration/backend:${VERSION_TAG}
    env_file:
      - settings/system/collaboration.env
      - settings/tenant1.env
      - settings/settings.share.env
    environment:
      - CALLBACK_URL=http://collaboration_tenant1:3333/callback
      - INTERNAL_HAPROXY_URL=http://haproxy_tenant1/
    volumes:
      - ./db_tenant1/:/db/
    hostname: collaboration_tenant1
    restart: on-failure
    container_name: collaboration_tenant1
    depends_on:
      - saver

  haproxy_tenant1:
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "5"
    image: ${DOCKER_REGISTRY}/collaboration/haproxy:${VERSION_TAG}
    hostname: haproxy
    environment:
      - COLLABORATION_SERVICE_ADDRESS=collaboration_tenant1:3333
    ports:
      - "8090:80"
    restart: on-failure
    container_name: haproxy_tenant1
    depends_on:
      - documentserver
      - collaboration_tenant1
      - staticfiles

  staticfiles:
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "5"
    hostname: staticfiles
    image: ${DOCKER_REGISTRY}/collaboration/static:${VERSION_TAG}
    restart: on-failure

  # Если необходимо отключать сервисы - задать расписание и окна. Подробнее см. в инструкции
  service-controller:
    image: ${DOCKER_REGISTRY}/collaboration/service-controller:${VERSION_TAG}
    depends_on:
      - documentserver
    environment:
      COMPOSE_PROJECT_NAME: "${COMPOSE_PROJECT_NAME}"
      CRON_TZ: Europe/Samara # в формате IANA
      # MAINTENANCE_START_TIME: |-
      #     20 23 * * *
      #     50 03 * * *
      # SERVICE_WINDOW: |-
      #     100m
      #     40m
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "5"
    restart: on-failure

  saver:
    image: ${DOCKER_REGISTRY}/collaboration/saver:${VERSION_TAG}
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "5"
    restart: on-failure
    environment:
      - DATA_FILE=/data/data.db
      - HTTP_PORT=80
    env_file:
      - settings/settings.share.env
    volumes:
      - ./saver/data/:/data
      - ./saver/storage:/storage
  documentserver:
    image: downloads.r7-office.ru:9010/r7office/documentserver-ee:2024.3.2.622
    depends_on:
      - postgres
      - redis
      - rabbit
      - saver
    volumes:
      - ./oo_data:/var/lib/r7-office/documentserver/App_Data
      - ./oo_logs:/var/log/r7-office
      - ./fonts:/usr/share/fonts
    env_file:
      - settings/system/oo.env
      - settings/settings.share.env
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "5"
    hostname: documentserver
    container_name: meta_documentserver
    restart: on-failure

  postgres:
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "5"
    hostname: postgres
    image: postgres:11
    env_file:
      - settings/system/oo.env
    volumes:
      - pg_volume:/var/lib/postgresql/data
    restart: on-failure

  rabbit:
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "5"
    hostname: rabbit
    image: rabbitmq:3
    restart: on-failure
    volumes:
      - rabbit_volume:/var/lib/rabbitmq
	  
  redis:
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "5"
    hostname: redis
    image: redis:5
    command: --appendonly yes
    restart: on-failure
    volumes:
      - redis_volume:/data

  logger:
    image: umputun/docker-logger
    hostname: "logger"
    restart: unless-stopped
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"
    environment:
      "LOG_FILES": "true"
      "LOG_SYSLOG": "false"
      "EXCLUDE": "docker-logger"
      "MAX_FILES": "999"
      "MAX_SIZE": "20"
      "MAX_AGE": "30"
      "DEBUG": "false"
      "TIME_ZONE": "Asia/Yekaterinburg"
    volumes:
      - ./logs:/srv/logs
      - /var/run/docker.sock:/var/run/docker.sock

volumes:
  rabbit_volume:
  pg_volume:
  redis_volume:
	  