Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Kambaa/dfd55985c567456fc9aa6e1fe8a6f84f to your computer and use it in GitHub Desktop.
Save Kambaa/dfd55985c567456fc9aa6e1fe8a6f84f to your computer and use it in GitHub Desktop.
Self-Hosted SeaFile 11 With SeaDoc Integration Enabled Docker Compose Settings ready to use on Dockge!
# Do not forget to use .env variable for the ${...} fields
# With this setup, if you have a domain and manage it on cloudflare,
# you can use the cloudflare tunnels and use seafile on your self hosting machine,
# on your subdomain(i.e: cloud.example.com and cloud-sdoc.example.com.tr for the sdoc-server)
version: "3.8"
services:
db:
restart: unless-stopped
image: mariadb:10.11
container_name: seafile-mysql
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_LOG_CONSOLE=true
- MARIADB_AUTO_UPGRADE=1
volumes:
- /opt/stacks/seafile/seafile-mysql/db:/var/lib/mysql
networks:
- seafile-net
ports:
- 3306:3306
memcached:
restart: unless-stopped
image: memcached:1.6.18
container_name: seafile-memcached
entrypoint: memcached -m 256
networks:
- seafile-net
av:
restart: unless-stopped
image: clamav/clamav:latest
container_name: seafile-clamav
networks:
- seafile-net
sdoc-server:
# installation steps: https://gist.github.com/Kambaa/dfd55985c567456fc9aa6e1fe8a6f84f
restart: unless-stopped
image: seafileltd/sdoc-server:latest
container_name: sdoc-server
volumes:
- /opt/stacks/seafile/seadoc-data:/shared
environment:
- DB_HOST=db
- DB_PORT=3306
- DB_USER=root
- DB_PASSWD=${MYSQL_ROOT_PASSWORD}
- DB_NAME=sdoc_db
- TIME_ZONE=Europe/Istanbul
- SDOC_SERVER_LETSENCRYPT=false # Whether to use https or not.
- SDOC_SERVER_HOSTNAME=cloud-sdoc.example.com.tr
- SEAHUB_SERVICE_URL=https://cloud.example.com.tr # http://192.168.1.222
ports:
- 7070:7070
- 8888:8888
networks:
- seafile-net
seafile:
restart: unless-stopped
image: docker.seadrive.org/seafileltd/seafile-pro-mc:11.0-latest
container_name: seafile
ports:
- 80:80
# - "443:443" # If https is enabled, cancel the comment.
volumes:
- /opt/stacks/seafile/seafile-data:/shared
environment:
- DB_HOST=db
- DB_ROOT_PASSWD=${MYSQL_ROOT_PASSWORD}
- SEAFILE_ADMIN_EMAIL=example@example.com
- SEAFILE_ADMIN_PASSWORD=${SEAFILE_ADMIN_PASSWORD}
- SEAFILE_SERVER_LETSENCRYPT=false # Whether to use https or not
- SEAFILE_SERVER_HOSTNAME=cloud.example.com.tr # for local only, set 192.168.1.222
depends_on:
- db
- memcached
- av
- sdoc-server
networks:
- seafile-net
- dockge_default
tunnel:
image: cloudflare/cloudflared:latest
restart: unless-stopped
command: tunnel run
environment:
- TUNNEL_TOKEN=${CLOUDFLARE_TUNNELS_TOKEN}
networks:
seafile-net: null
dockge_default:
external: true

How to enable Seadoc integration on Seafile 11 (via docker compose on same machine, on mariadb)

I had a hard time reading, understanding and applying the steps on the manual(https://manual.seafile.com/extra_setup/setup_seadoc/). After i made it work, i logged the steps below. I Hope this helps somebody.

To use both seadoc and seafile on a same docker compose file:

1. add db and privileges:

In my setup, i used mariadb so connect to it and add these commands to add new db and set the privileges:

create database if not exists sdoc_db charset utf8mb4;
GRANT ALL PRIVILEGES ON `sdoc_db`.* to `seafile`@`%.%.%.%`;

2. add docker compose service:

Update as your needs and add to your compose file

sdoc-server:
    image: seafileltd/sdoc-server:latest
    container_name: sdoc-server
    volumes:
      - /opt/stacks/seafile/seadoc-data:/shared
    environment:
      - DB_HOST=db  # my mariadb docker compose service name
      - DB_PORT=3306  
      - DB_USER=${MYSQL_USERNAME}
      - DB_PASSWD=${MYSQL_PASSWORD}
      - DB_NAME=sdoc_db
      - TIME_ZONE=Europe/Istanbul 
      - SDOC_SERVER_LETSENCRYPT=false # Whether to use https or not.
      - SDOC_SERVER_HOSTNAME=seafile.example.com # Specifies your host name if https is enabled.
      - SEAHUB_SERVICE_URL=http://seafile.example.com
    ports:
      - 7070:7070
    # - 8888:8888
      

3. Run first time successfully and open the file and get the value defined in key named "private_key":

/opt/stacks/seafile/seadoc-data/sdoc-server/conf/sdoc_server_config.json

4. Update Seafile settings:

For my setup, Seafile's docker compose volume config is setup at /opt/stacks/seafile/seafile-data/ below are written according to this, so update locations to your specific setup.

Open the file addressed below:

/opt/stacks/seafile/seafile-data/seafile/conf/seahub_settings.py 

Add these line at the bottom to activate the Seadoc integration. Remember to update the private key info from the copied value described above, hostname and port information(Port info is defined in the compose file) according to your needs.

# SeaDoc Integration
ENABLE_SEADOC = True
SEADOC_PRIVATE_KEY = 'ENTER_PRIVATE_KEY_HERE'  # sdoc-server private_key
SEADOC_SERVER_URL = 'http://seafile.example.com:7070'  # sdoc-server service url use the port defined above
# When SeaDoc and Seafile/Seafile docker are deployed on the same host, SEADOC_SERVER_URL should be 'https://seafile.example.com/sdoc-server'
FILE_CONVERTER_SERVER_URL = 'http://sdoc-server:8888'  # converter-server url
# When SeaDoc and Seafile are deployed on the same host, FILE_CONVERTER_SERVER_URL should be LAN address 'http://127.0.0.1:8888'
# When SeaDoc and Seafile docker are deployed on the same host, FILE_CONVERTER_SERVER_URL should be http://sdoc-server:8888

After that open

/opt/stacks/seafile/seafile-data/nginx/conf/seafile.nginx.conf

and add these below:

# SEADOC INTEGRATION CONFIG
location /sdoc-server/ {
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
    add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
    if ($request_method = 'OPTIONS') {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
        add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
        return 204;
    }

    proxy_pass         http://sdoc-server:7070;
    proxy_redirect     off;
    proxy_set_header   Host              $host;
    proxy_set_header   X-Real-IP         $remote_addr;
    proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Host  $server_name;
    proxy_set_header   X-Forwarded-Proto $scheme;

    client_max_body_size 100m;
}

location /socket.io {
    proxy_pass http://sdoc-server:7070;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_redirect off;

    proxy_buffers 8 32k;
    proxy_buffer_size 64k;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
}

5. Lastly, make a restart:

docker compose down
docker compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment