networks:
  seafile-net:
    name: seafile-net
    driver: bridge

services:
  db:
    image: mariadb:10.11
    container_name: seafile-mysql
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_LOG_CONSOLE=true
      - MARIADB_AUTO_UPGRADE=1
    volumes:
      - /mnt/user/appdata/seafile/db-data:/var/lib/mysql
    networks:
      - seafile-net
    healthcheck:
      test: ["CMD", "sh", "-c", "mysqladmin ping -h localhost -u root -p$$MYSQL_ROOT_PASSWORD"]
      interval: 20s
      start_period: 30s
      timeout: 5s
      retries: 10

  redis:
    image: redis:latest
    container_name: seafile-redis
    restart: unless-stopped
    networks:
      - seafile-net

  seafile:
    image: seafileltd/seafile-pro-mc:13.0.6-testing
    container_name: seafile
    restart: unless-stopped
    ports:
      - 8098:80
    environment:
      - SEAFILE_MYSQL_DB_HOST=db
      - SEAFILE_MYSQL_DB_PORT=3306
      - SEAFILE_MYSQL_DB_USER=seafile
      - SEAFILE_MYSQL_DB_PASSWORD=${SEAFILE_MYSQL_DB_PASSWORD}
      - SEAFILE_MYSQL_DB_CCNET_DB_NAME=ccnet_db
      - SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=seafile_db
      - SEAFILE_MYSQL_DB_SEAHUB_DB_NAME=seahub_db
      - TIME_ZONE=Etc/UTC
      - SEAFILE_SERVER_HOSTNAME=${SEAFILE_SERVER_HOSTNAME}
      - SEAFILE_SERVER_PROTOCOL=https
      - JWT_PRIVATE_KEY=${JWT_PRIVATE_KEY}
      - ENABLE_SEADOC=true
      - SEADOC_SERVER_URL=https://${SEAFILE_SERVER_HOSTNAME}/sdoc-server
      - CACHE_PROVIDER=redis
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - INNER_NOTIFICATION_SERVER_URL=http://notification-server:8083
      - NOTIFICATION_SERVER_URL=${NOTIFICATION_SERVER_URL}
    volumes:
      - /mnt/user/appdata/seafile/data:/shared
      - /mnt/user/appdata/seafile/seahub_settings.py:/shared/seafile/conf/seahub_settings.py
      - /mnt/user/appdata/seafile/seafile.conf:/shared/seafile/conf/seafile.conf
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
    networks:
      - seafile-net

  seadoc:
    image: seafileltd/sdoc-server:2.0.3-testing
    container_name: seadoc
    restart: unless-stopped
    ports:
      - 8888:80
    environment:
      - DB_HOST=db
      - DB_PORT=3306
      - DB_USER=seafile
      - DB_PASSWORD=${SEAFILE_MYSQL_DB_PASSWORD}
      - DB_NAME=seahub_db
      - TIME_ZONE=Etc/UTC
      - JWT_PRIVATE_KEY=${JWT_PRIVATE_KEY}
      - SEAHUB_SERVICE_URL=https://${SEAFILE_SERVER_HOSTNAME}
    volumes:
      - /mnt/user/appdata/seafile/seadoc-data:/shared
    depends_on:
      db:
        condition: service_healthy
    networks:
      - seafile-net

  notification-server:
    image: seafileltd/notification-server:13.0.0-testing
    container_name: notification-server
    restart: unless-stopped
    ports:
      - 8083:8083
    environment:
      - SEAFILE_MYSQL_DB_HOST=db
      - SEAFILE_MYSQL_DB_PORT=3306
      - SEAFILE_MYSQL_DB_USER=seafile
      - SEAFILE_MYSQL_DB_PASSWORD=${SEAFILE_MYSQL_DB_PASSWORD}
      - SEAFILE_MYSQL_DB_CCNET_DB_NAME=ccnet_db
      - SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=seafile_db
      - JWT_PRIVATE_KEY=${JWT_PRIVATE_KEY}
      - SEAFILE_LOG_TO_STDOUT=true
    volumes:
      - /mnt/user/appdata/seafile/data/seafile/logs:/shared/seafile/logs
    depends_on:
      db:
        condition: service_healthy
    networks:
      - seafile-net

  seafile-md-server:
    image: seafileltd/seafile-md-server:13.0.6-testing
    container_name: seafile-md-server
    restart: unless-stopped
    ports:
      - 8084:8084
    environment:
      - JWT_PRIVATE_KEY=${JWT_PRIVATE_KEY}
      - SEAFILE_MYSQL_DB_HOST=db
      - SEAFILE_MYSQL_DB_PORT=3306
      - SEAFILE_MYSQL_DB_USER=seafile
      - SEAFILE_MYSQL_DB_PASSWORD=${SEAFILE_MYSQL_DB_PASSWORD}
      - SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=seafile_db
      - MD_PORT=8084
      - MD_STORAGE_TYPE=s3
      - S3_MD_BUCKET=seafile-md
      - S3_KEY_ID=${S3_KEY_ID}
      - S3_SECRET_KEY=${S3_SECRET_KEY}
      - S3_AWS_REGION=us-east-1
      - S3_HOST=s3.amazonaws.com
      - S3_USE_HTTPS=true
      - S3_USE_V4_SIGNATURE=true
      - CACHE_PROVIDER=redis
      - REDIS_HOST=redis
      - REDIS_PORT=6379
    volumes:
      - /mnt/user/appdata/seafile/data:/shared
    depends_on:
      db:
        condition: service_healthy
    networks:
      - seafile-net

  seasearch:
    image: seafileltd/seasearch:1.0.1-testing
    container_name: seafile-seasearch
    restart: unless-stopped
    ports:
      - 4080:4080
    environment:
      - SS_MAX_OBJ_CACHE_SIZE=10GB
      - SS_STORAGE_TYPE=disk
      - SS_LOG_TO_STDOUT=true
      - SS_LOG_LEVEL=info
    volumes:
      - /mnt/user/appdata/seafile/seasearch-data:/opt/seasearch/data
    networks:
      - seafile-net
