# documentation: https://owncloud.com/docs-guides/
# slogan: OwnCloud with Open Web UI integrates file management with a powerful, user-friendly interface.
# category: storage
# tags: owncloud,file-management,open-web-ui,integration,cloud
# logo: svgs/owncloud.svg
# port: 8080

services:
  owncloud:
    image: owncloud/server:latest
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
    environment:
      - SERVICE_URL_OWNCLOUD_8080
      - OWNCLOUD_DOMAIN=${SERVICE_FQDN_OWNCLOUD}
      - OWNCLOUD_TRUSTED_DOMAINS=${SERVICE_FQDN_OWNCLOUD}
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_HOST=mariadb
      - OWNCLOUD_DB_NAME=${DB_NAME:-owncloud}
      - OWNCLOUD_DB_USERNAME=${SERVICE_USER_MARIADB}
      - OWNCLOUD_DB_PASSWORD=${SERVICE_PASSWORD_MARIADB}
      - OWNCLOUD_ADMIN_USERNAME=${SERVICE_USER_OWNCLOUD}
      - OWNCLOUD_ADMIN_PASSWORD=${SERVICE_PASSWORD_OWNCLOUD}
      - OWNCLOUD_MYSQL_UTF8MB4=${MYSQL_UTF8MB4:-true}
      - OWNCLOUD_REDIS_ENABLED=${REDIS_ENABLED:-true}
      - OWNCLOUD_REDIS_HOST=redis
    healthcheck:
      test:
        - CMD
        - /usr/bin/healthcheck
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - owncloud-data:/mnt/data

  mariadb:
    image: mariadb:latest
    environment:
      - MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MARIADBROOT}
      - MYSQL_USER=${SERVICE_USER_MARIADB}
      - MYSQL_PASSWORD=${SERVICE_PASSWORD_MARIADB}
      - MYSQL_DATABASE=${DB_NAME:-owncloud}
      - TZ=auto
    command:
      - "--character-set-server=utf8mb4"
      - "--collation-server=utf8mb4_bin"
      - "--max-allowed-packet=128M"
      - "--innodb-log-file-size=64M"
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 5s
      timeout: 20s
      retries: 10
    volumes:
      - owncloud-mysql-data:/var/lib/mysql

  redis:
    image: redis:6
    command:
      - "--databases"
      - "1"
    healthcheck:
      test:
        - CMD
        - redis-cli
        - ping
      interval: 10s
      timeout: 5s
      retries: 5
