services:
  db:
    image: mariadb:11.8
    command: --max-allowed-packet=209715210
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: &MYSQL_DATABASE tine
      MYSQL_USER: &MYSQL_USER tine
      MYSQL_PASSWORD: &MYSQL_PASSWORD tine
      MARIADB_AUTO_UPGRADE: 1
    ### use volume for persistent DB
    volumes:
      - "tine_db:/var/lib/mysql"
    ### OR
#      - "./data/tine_mysql:/var/lib/mysql"
    networks:
      - internal_network

  web:
    image: tinegroupware/tine:2025
    restart: always
    depends_on:
      - db
      - cache
    environment:
      TINE20_DATABASE_HOST: db
      TINE20_DATABASE_DBNAME: *MYSQL_DATABASE
      TINE20_DATABASE_USERNAME: *MYSQL_USER
      TINE20_DATABASE_PASSWORD: *MYSQL_PASSWORD
      TINE20_DATABASE_TABLEPREFIX: tine_
      TINE20_CACHING_BACKEND: Redis
      TINE20_CACHING_REDIS_HOST: cache
      TINE20_ACTIONQUEUE_HOST: cache
      TINE20_SESSION_BACKEND: Redis
      TINE20_SESSION_HOST: cache
      TINE20_CREDENTIALCACHESHAREDKEY: change_me
      TINE20_SETUPUSER_USERNAME: tinesetup
      TINE20_SETUPUSER_PASSWORD: tinesetup
      TINE20_SETUP_HTPASSWD: "setup:$$apr1$$JhCtViTh$$k15DH.HvNR5hZ66Ew5aTH/" #setup:setuppw
      TINE20_ACTIONQUEUE: "true"
      BROADCASTHUB_URL: http://broadcasthub
      # TINE20_LOGGER_PRIORITY: "7"
      ### the url of you tine installation (should be adjusted)
      # TINE20_URL: http://localhost:4000
      ### install+update tine automatically
      # TINE20_INSTALL: "true"
      ### needed for auto-install
      # TINE20_ACCEPTED_TERMS_VERSION: 10000
      # TINE20_LOGIN_USERNAME: admin
      # TINE20_LOGIN_PASSWORD: change_me
      ### apps to install - if omitted, all available apps are installed
      # TINE20_APPLICATION_TO_INSTALL: "Addressbook,Felamimail,Calendar,Filemanager"

    volumes:
      - "tine_files:/var/lib/tine20/files"
      # use this for custom configuration files (like logger.inc.php)
      - "./conf.d:/etc/tine20/conf.d"
    ### OR
      # NOTE: you need to make sure that the folder has the correct file permissions
#      - "./data/tine_files:/var/lib/tine20/files"
    networks:
      - external_network
      - internal_network
    ports:
      - "127.0.0.1:4000:80"
    ### for traefik support (see https://doc.traefik.io/traefik/providers/docker/)
#    labels:
#      - "traefik.enable=true"
#      - "traefik.http.routers.web.rule=Host(`MYDOMAIN.de`)"
#      - "traefik.http.routers.web.entrypoints=websecure"
#      - "traefik.http.routers.web.tls.certresolver=http01"
#      - "traefik.http.services.web.loadbalancer.server.port=80"

  cache:
    image: valkey/valkey:9.0
    restart: always
    networks:
      - internal_network

  broadcasthub:
    image: tinegroupware/broadcasthub:0.7
    restart: always
    networks:
      - external_network
      - internal_network
    ports:
      - "5001:80"
    environment:
      REDIS_URL: redis://cache:6379
      REDIS_CHANNEL: broadcasthub
      TINE20_JSON_API_URL: http://localhost
      AUTH_TIMEOUT: 5000
      WS_PORT: 80
      DEBUG: '*'
      DEBUG_DEFAULT_LOGGING: "on"
      DEBUG_LOG_TO_FILE: "off"
      DEBUG_LOG_FILE: ../../stdout.log
      ENABLE_MULTITENANCY_MODE: false

### other optional services

############################################################################
# docservice
############
# to use this in tine, you need to add the following to your config:
#
# 'filesystem' => [
#   'createPreviews' => true,
#   'previewServiceUrl' => 'http://docservice/v2/documentPreviewService',
#   'previewServiceVersion' => 2,
#   [...]
# ],
############################################################################
#  docservice:
#    image: tinegroupware/document-preview-service:2.1
#    restart: always
#    networks:
#      - internal_network

############################################################################
#  documentserver
############################################################################
#
# to use this in tine, you need to add the following to your config:
#
# return [
#    'OnlyOfficeIntegrator' => [
#        'onlyOfficePublicUrl' => 'http://localhost:4020/',
#        'onlyOfficeServerUrl' => 'http://documentserver/',
#        'tine20ServerUrl' => 'http://web/',
#        'jwtEnabled' => true,
#        'jwtSecret' => 'change_me_also_define_in_tine_cfg',
#    ],
#
############################################################################
#  documentserver:
#    image: onlyoffice/documentserver:latest
#    restart: always
#    ports:
#      - "4020:80"
#    environment:
#      JWT_ENABLED: "true"
#      JWT_SECRET: "change_me_also_define_in_tine_cfg"
#    networks:
#      - external_network
#      - internal_network

#  clamav:
#    image: tiredofit/clamav
#    restart: always
#    container_name: clamav
#    environment:
#      - ZABBIX_HOSTNAME=clamav
#    # need to be created on the host
#    volumes:
#      - "clamav_files:/data"
#    networks:
#      - internal_network

#  traefik:
#    image: "traefik:v3.6"
#    restart: always
#    container_name: "traefik"
#    command:
#      - "--providers.docker=true"
#      - "--providers.docker.exposedbydefault=false"
#      - "--entrypoints.web.address=:80"
#      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
#      - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
#      - "--entrypoints.web.http.redirections.entrypoint.permanent=true"
#      - "--entrypoints.websecure.address=:443"
#      - "--certificatesresolvers.http01.acme.httpchallenge=true"
#      - "--certificatesresolvers.http01.acme.httpchallenge.entrypoint=web"
#      - "--certificatesresolvers.http01.acme.storage=/letsencrypt/acme.json"
#    ports:
#      - "80:80"
#      - "443:443"
#      - "8080:8080"
#    volumes:
#      - "./letsencrypt:/letsencrypt"
#      - "/var/run/docker.sock:/var/run/docker.sock:ro"

############################################################################
#  edocument
############################################################################
#
#  return [
#    'Sales' => [
#        'edocument' => [
#            'validation_svc' => 'http://edocument:3000/ubl',
#            'view_svc' => 'http://edocument:3000/ublView',
#        ],
#    ],
#];
#
#   edocument:
#     image: registry.rz1.metaways.net/tine/edocument-services:0.0.14-amd64
#     restart: always
#     ports:
#       - "3000:3000"
#     networks:
#       - internal_network

### if you use directory mounts, you might no need that
volumes:
  tine_files:
  tine_db:
#  clamav_files:

networks:
  external_network:
  internal_network:
    internal: true
