version: '3'

services:
    owncloud:
        image: owncloud/server:10.10.0
        ports:
            - 5566:8080
        depends_on:
            mariadb:
                condition: service_healthy
        environment:
            - OWNCLOUD_DOMAIN=http://localhost:5566
            - OWNCLOUD_TRUSTED_DOMAINS=
            - OWNCLOUD_DB_TYPE=mysql
            - OWNCLOUD_DB_NAME=owncloud
            - OWNCLOUD_DB_USERNAME=owncloud
            - OWNCLOUD_DB_PASSWORD=owncloud
            - OWNCLOUD_DB_HOST=mariadb
            - OWNCLOUD_ADMIN_USERNAME=admin
            - OWNCLOUD_ADMIN_PASSWORD=admin
            - OWNCLOUD_MYSQL_UTF8MB4=true
            - OWNCLOUD_REDIS_ENABLED=false
            - OWNCLOUD_REDIS_HOST=false
        healthcheck:
            test: ['CMD', '/usr/bin/healthcheck']
            interval: 30s
            timeout: 10s
            retries: 5
        volumes:
            - ./oc_tmp/files:/mnt/data
            - ./08-skeleton.sh:/etc/entrypoint.d/08-skeleton.sh

    mariadb:
        image: mariadb:10.11
        environment:
            - MYSQL_ROOT_PASSWORD=owncloud
            - MYSQL_USER=owncloud
            - MYSQL_PASSWORD=owncloud
            - MYSQL_DATABASE=owncloud
            - MARIADB_AUTO_UPGRADE=1
        command: ['--max-allowed-packet=128M', '--innodb-log-file-size=64M']
        healthcheck:
            test: ['CMD', 'mysqladmin', 'ping', '-u', 'root', '--password=owncloud']
            interval: 10s
            timeout: 5s
            retries: 5
        volumes:
            - ./oc_tmp/db:/var/lib/mysql

    nextclouddb:
        image: mariadb:10.6
        command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
        healthcheck:
            test: ['CMD', 'mysqladmin', 'ping', '-u', 'root', '--password=secret']
            interval: 10s
            timeout: 5s
            retries: 5
        volumes:
            - ./oc_tmp/ncdb:/var/lib/mysql
        environment:
            - MYSQL_ROOT_PASSWORD=secret
            - MYSQL_PASSWORD=secret
            - MYSQL_DATABASE=nextcloud
            - MYSQL_USER=nextcloud

    app:
        image: nextcloud
        restart: always
        depends_on:
            nextclouddb:
                condition: service_healthy
        ports:
            - 5567:80
        environment:
            - MYSQL_PASSWORD=secret
            - MYSQL_DATABASE=nextcloud
            - MYSQL_USER=nextcloud
            - MYSQL_HOST=nextclouddb
            - NEXTCLOUD_ADMIN_USER=admin
            - NEXTCLOUD_ADMIN_PASSWORD=admin
            - NEXTCLOUD_TRUSTED_DOMAINS=