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:
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`@`%.%.%.%`;
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
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;
}
docker compose down
docker compose up -d