version: '3'

services:
  application:
    image: "nextcloud:{{version_nextcloud}}-fpm-alpine"
    restart: always
    logging:
      driver: journald
    depends_on:
      - database
    volumes:
      - data:/var/www/html
    environment:
      MYSQL_DATABASE: "nextcloud"
      MYSQL_USER: "nextcloud"
      MYSQL_PASSWORD: "{{nextcloud_database_password}}"
      MYSQL_HOST: database:3306
  database:
    logging:
      driver: journald
    image: mariadb:10.5
    command: "--transaction-isolation=READ-COMMITTED --binlog-format=ROW"
    environment:
      MYSQL_DATABASE: "nextcloud"
      MYSQL_USER: "nextcloud"
      MYSQL_PASSWORD: "{{nextcloud_database_password}}"
      MYSQL_ROOT_PASSWORD: "{{nextcloud_database_password}}"
      MARIADB_AUTO_UPGRADE: "1"
    volumes:
      - database:/var/lib/mysql
    restart: always
    healthcheck:
      test: "/usr/bin/mariadb --user=nextcloud --password={{nextcloud_database_password}} --execute \"SHOW DATABASES;\""
      interval: 3s
      timeout: 1s
      retries: 5
  web:
    image: nginx:alpine
    logging:
      driver: journald
    restart: always
    ports:
      - "127.0.0.1:{{http_port}}:80"
    depends_on:
      - application
    volumes:
        - "{{path_docker_volumes}}nextcloud/nginx.conf:/etc/nginx/nginx.conf:ro"
    volumes_from:
      - application
  redis:
    image: redis:alpine
    restart: always
    logging:
      driver: journald
    volumes:
      - redis:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 1s
      timeout: 3s
      retries: 30
  cron:
    image: "nextcloud:{{version_nextcloud}}-fpm-alpine"
    restart: always
    logging:
      driver: journald
    volumes:
      - data:/var/www/html
    entrypoint: /cron.sh
    depends_on:
      - database
      - redis
volumes:
  database:
  data:
  redis:
networks:
  default:
    driver: bridge