version: '3.7'
services:
  db:
    image: mariadb:10.5
    container_name: seafile-mysql
    environment:
      - MYSQL_ROOT_PASSWORD=db_dev  # Requested, set the root's password of MySQL service.
      - MYSQL_LOG_CONSOLE=true
    volumes:
      - /D/seafile/opt/seafile-mysql/db:/seafile-mysql/db/var/lib/mysql  # Requested, specifies the path to MySQL data persistent store.
    networks:
      - seafile-net
    restart: always
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "--silent"]
      interval: 60s
      timeout: 35s
      retries: 1
      start_period: 45s       

  memcached:
    image: memcached:1.6
    container_name: seafile-memcached
    entrypoint: memcached -m 256
    networks:
      - seafile-net
    restart: always
    healthcheck:
      test: ["CMD", "echo", "stats", "|", "nc", "127.0.0.1", "11211"]
      interval: 60s
      timeout: 35s
      retries: 1
      start_period: 45s     
          
  seafile:
    image: seafileltd/seafile-mc:9.0.4
    container_name: seafile
    ports:     
      - "8000:80"
      - "8082:8082"
#     - "443:443"  # If https is enabled, cancel the comment.   
    volumes:
      - /D/seafile/opt/seafile-data:/shared  # Requested, specifies the path to Seafile data persistent store.
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=db_dev  # Requested, the value shuold be root's password of MySQL service.
      - TIME_ZONE=America/New_York  # Optional, default is UTC. Should be uncomment and set to your local time zone.
      - SEAFILE_ADMIN_EMAIL=me@example.com # Specifies Seafile admin user, default is 'me@example.com'.
      - SEAFILE_ADMIN_PASSWORD=password     # Specifies Seafile admin password, default is 'asecret'.
      - SEAFILE_SERVER_LETSENCRYPT=false   # Whether to use https or not.
      - SEAFILE_SERVER_HOSTNAME=192.168.1.150 # Specifies your host name if https is enabled.
    depends_on:
      - db
      - memcached
    networks:
      - seafile-net
    restart: always
    healthcheck:
      test: ["CMD", "curl", "-f", "127.0.0.1:80"]
      interval: 60s
      timeout: 35s
      retries: 1
      start_period: 60s  
    labels:
    - "autoheal=true"
    
  autoheal:
    image: willfarrell/autoheal:1.2.0
    tty: true
    container_name: autoheal
    restart: always
    environment:
      - AUTOHEAL_CONTAINER_LABEL=all
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

networks:
  seafile-net: