# Seafile File Sync & Share

> Enterprise file sync and share platform with versioning, encryption, and team collaboration.

- Category: Storage & Backup
- Difficulty: intermediate
- Components: seafile, memcached, mariadb, nginx
- Tags: seafile, sync, share, enterprise, collaboration
- Source: https://docker.recipes/storage/seafile-cloud-storage

## Overview

Seafile is an enterprise-grade open-source file synchronization and sharing platform developed by a team that previously worked on version control systems, bringing Git-like versioning concepts to file management. Originally created in 2012, Seafile distinguishes itself from competitors like Nextcloud or ownCloud through its unique block-level deduplication, client-side encryption capabilities, and distributed architecture that can scale to handle millions of files efficiently. The platform offers desktop clients for Windows, Mac, and Linux, mobile apps for iOS and Android, and a comprehensive web interface for browser-based access.

This stack combines Seafile with MariaDB for metadata storage, Memcached for session and object caching, and relies on Seafile's built-in web server for HTTP handling. MariaDB stores all file metadata, user information, and sharing permissions while the actual file data is stored in Seafile's proprietary storage format with block-level deduplication. Memcached accelerates the system by caching frequently accessed database queries, user sessions, and file metadata, significantly improving response times for large deployments with hundreds of concurrent users.

This configuration targets organizations requiring enterprise-level file collaboration with strong security controls, detailed audit trails, and the ability to maintain complete data sovereignty. Unlike cloud-based solutions, this self-hosted stack gives administrators full control over encryption keys, data location, and compliance requirements while providing features like remote device wipe, detailed access logs, and integration with LDAP/Active Directory for user management.

## Features

- Block-level file deduplication reduces storage requirements by up to 90% for organizations with similar documents
- Client-side encryption with user-controlled keys ensures files remain encrypted even from system administrators
- Git-like file versioning with complete revision history and ability to restore any previous version
- MariaDB Aria storage engine provides crash-safe metadata storage with automatic recovery
- Memcached integration eliminates database bottlenecks during high concurrent access scenarios
- Two-way sync clients for desktop maintain offline access with conflict resolution
- Library-based organization allows granular sharing permissions at folder level rather than entire accounts
- WebDAV and RESTful API support enables integration with third-party applications and mobile workflows

## Use cases

- Law firms requiring client-privileged document sharing with audit trails and remote wipe capabilities
- Engineering teams collaborating on CAD files and technical drawings with version control and large file handling
- Healthcare organizations needing HIPAA-compliant file sharing with patient data encryption and access logging
- Educational institutions providing secure file storage for faculty and students with departmental isolation
- Remote development teams synchronizing code repositories and documentation across multiple time zones
- Financial services firms sharing sensitive documents with clients while maintaining regulatory compliance
- Manufacturing companies distributing technical specifications and quality documents to global facilities

## Prerequisites

- Minimum 2GB RAM for MariaDB metadata storage and Seafile processing (4GB+ recommended for 50+ users)
- Port 80 and 443 available for Seafile web interface and client synchronization
- Valid SSL certificate or domain name for secure client connections and mobile app access
- Understanding of Seafile library concepts and permission models for proper organization setup
- Basic knowledge of MariaDB backup procedures for protecting user data and sharing configurations
- SMTP server configuration for user invitation emails and password reset functionality

## docker-compose.yml

```yaml
services:
  seafile:
    image: seafileltd/seafile-mc:latest
    environment:
      DB_HOST: mariadb
      DB_ROOT_PASSWD: ${MYSQL_ROOT_PASSWORD}
      SEAFILE_ADMIN_EMAIL: ${ADMIN_EMAIL}
      SEAFILE_ADMIN_PASSWORD: ${ADMIN_PASSWORD}
      SEAFILE_SERVER_LETSENCRYPT: "false"
      SEAFILE_SERVER_HOSTNAME: ${SERVER_HOSTNAME}
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - seafile_data:/shared
    depends_on:
      - mariadb
      - memcached
    networks:
      - seafile-net
    restart: unless-stopped

  mariadb:
    image: mariadb:10.11
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    volumes:
      - mariadb_data:/var/lib/mysql
    networks:
      - seafile-net
    restart: unless-stopped

  memcached:
    image: memcached:alpine
    networks:
      - seafile-net
    restart: unless-stopped

volumes:
  seafile_data:
  mariadb_data:

networks:
  seafile-net:
    driver: bridge
```

## .env

```bash
# MariaDB
MYSQL_ROOT_PASSWORD=secure_root_password

# Seafile Admin
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=secure_admin_password

# Server
SERVER_HOSTNAME=seafile.example.com
```

## Usage notes

- Web UI at http://localhost
- Desktop and mobile clients available
- File versioning and encryption
- Team and group management

## Troubleshooting

- Seafile service fails to start with database connection error: Verify MYSQL_ROOT_PASSWORD environment variable matches between mariadb and seafile services
- Desktop clients cannot sync with 'SSL certificate verify failed': Ensure SEAFILE_SERVER_HOSTNAME matches your actual domain name and SSL certificate
- File uploads fail with 'Request Entity Too Large': Modify Seafile's seahub_settings.py to increase FILE_UPLOAD_MAX_MEMORY_SIZE beyond default 200MB
- Slow performance during peak usage: Monitor memcached hit rates and increase memcached memory allocation or add additional memcached instances
- Users cannot access shared libraries: Check Seafile database ccnet-db for proper group memberships and sharing permissions in the EmailUser and Group tables
- MariaDB crashes during large file operations: Increase innodb_buffer_pool_size to at least 1GB and set innodb_log_file_size to 256MB for better transaction handling

