From 9cc8d337fe716767fb3898909cfda5937be9de33 Mon Sep 17 00:00:00 2001 From: Rik Veenboer Date: Sun, 1 Dec 2024 14:39:04 +0100 Subject: [PATCH] simplify seafile docker compose --- .gitignore | 6 +- docker-compose.seafile.yml | 23 +----- seafile/.env | 33 -------- seafile/docker-compose.yml | 56 ------------- seafile/server/nginx/conf/seafile.nginx.conf | 79 +++++++++++++++++++ seafile/server/seafile/conf/gunicorn.conf.py | 16 ++++ seafile/server/seafile/conf/seafdav.conf | 4 + seafile/server/seafile/conf/seafevents.conf | 22 ++++++ seafile/server/seafile/conf/seafile.conf | 11 +++ .../server/seafile/conf/seahub_settings.py | 16 ++++ 10 files changed, 153 insertions(+), 113 deletions(-) delete mode 100644 seafile/.env delete mode 100644 seafile/docker-compose.yml create mode 100644 seafile/server/nginx/conf/seafile.nginx.conf create mode 100644 seafile/server/seafile/conf/gunicorn.conf.py create mode 100644 seafile/server/seafile/conf/seafdav.conf create mode 100644 seafile/server/seafile/conf/seafevents.conf create mode 100644 seafile/server/seafile/conf/seafile.conf create mode 100755 seafile/server/seafile/conf/seahub_settings.py diff --git a/.gitignore b/.gitignore index 7b27451..d1fc688 100644 --- a/.gitignore +++ b/.gitignore @@ -77,10 +77,8 @@ radarr/Sentry/ radarr/asp/ radarr/xdg/ rsnapshot/var/ -seafile/ccnet/ -seafile/seafile-data/ -seafile/seahub-data/ -seafile/version +seafile/database/ +seafile/server/ sonarr/Backups/ sonarr/MediaCover/ sonarr/Sentry/ diff --git a/docker-compose.seafile.yml b/docker-compose.seafile.yml index 962aee8..e494f64 100644 --- a/docker-compose.seafile.yml +++ b/docker-compose.seafile.yml @@ -7,7 +7,8 @@ services: - MYSQL_LOG_CONSOLE=true - MARIADB_AUTO_UPGRADE=1 volumes: - - /opt/seafile/db:/var/lib/mysql + - /opt/seafile/database:/var/lib/mysql + healthcheck: test: [ @@ -28,7 +29,7 @@ services: ports: - "8082:80" volumes: - - /opt/seafile/data:/shared + - /opt/seafile/server:/shared - /media/sync/seafile:/shared/seafile/seafile-data environment: - DB_HOST=seafile-mysql @@ -41,23 +42,5 @@ services: - SEAFILE_SERVER_HOSTNAME=seafile.rik.veenboer.xyz - SEAFILE_SERVER_PROTOCOL=https - JWT_PRIVATE_KEY=8LzWzeuQ41z1i8fc1cr1L7Kw80VpTgmT - - # - DB_HOST=${SEAFILE_MYSQL_DB_HOST:-db} - # - DB_PORT=${SEAFILE_MYSQL_DB_PORT:-3306} - # - DB_ROOT_PASSWD=${INIT_SEAFILE_MYSQL_ROOT_PASSWORD:-} - # - DB_PASSWORD=${SEAFILE_MYSQL_DB_PASSWORD:?Variable is not set or empty} - - SEAFILE_MYSQL_DB_CCNET_DB_NAME=${SEAFILE_MYSQL_DB_CCNET_DB_NAME:-ccnet_db} - - SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=${SEAFILE_MYSQL_DB_SEAFILE_DB_NAME:-seafile_db} - - SEAFILE_MYSQL_DB_SEAHUB_DB_NAME=${SEAFILE_MYSQL_DB_SEAHUB_DB_NAME:-seahub_db} - # - TIME_ZONE=${TIME_ZONE:-Etc/UTC} - # - INIT_SEAFILE_ADMIN_EMAIL=${INIT_SEAFILE_ADMIN_EMAIL:-me@example.com} - # - INIT_SEAFILE_ADMIN_PASSWORD=${INIT_SEAFILE_ADMIN_PASSWORD:-asecret} - # - SEAFILE_SERVER_HOSTNAME=${SEAFILE_SERVER_HOSTNAME:?Variable is not set or empty} - # - SEAFILE_SERVER_PROTOCOL=${SEAFILE_SERVER_PROTOCOL:-http} - - SITE_ROOT=${SITE_ROOT:-/} - - NON_ROOT=${NON_ROOT:-false} - # - JWT_PRIVATE_KEY=${JWT_PRIVATE_KEY:?Variable is not set or empty} - - ENABLE_SEADOC=${ENABLE_SEADOC:-false} - - SEADOC_SERVER_URL=${SEADOC_SERVER_URL:-http://example.example.com/sdoc-server} depends_on: - seafile-mysql diff --git a/seafile/.env b/seafile/.env deleted file mode 100644 index 1ce8727..0000000 --- a/seafile/.env +++ /dev/null @@ -1,33 +0,0 @@ -SEAFILE_IMAGE=seafileltd/seafile-mc:12.0-latest -SEAFILE_DB_IMAGE=mariadb:10.11 -SEAFILE_MEMCACHED_IMAGE=memcached:1.6.29 -SEAFILE_CADDY_IMAGE=lucaslorentz/caddy-docker-proxy:2.9 - -SEAFILE_VOLUME=/opt/seafile/data -SEAFILE_MYSQL_VOLUME=/opt/seafile/db -SEAFILE_CADDY_VOLUME=/opt/seafile/caddy - -SEAFILE_MYSQL_DB_HOST=db -INIT_SEAFILE_MYSQL_ROOT_PASSWORD=ROOT_PASSWORD -SEAFILE_MYSQL_DB_USER=seafile -SEAFILE_MYSQL_DB_PASSWORD=PASSWORD - -TIME_ZONE=Europe/Amsterdam - -JWT_PRIVATE_KEY=8LzWzeuQ41z1i8fc1cr1L7Kw80VpTgmT - -SEAFILE_SERVER_HOSTNAME=seafile.rik.veenboer.xyz -SEAFILE_SERVER_PROTOCOL=https - -INIT_SEAFILE_ADMIN_EMAIL=admin@rik.veenboer.xyz -INIT_SEAFILE_ADMIN_PASSWORD=asecret - - -SEADOC_IMAGE=seafileltd/sdoc-server:1.0-latest -SEADOC_VOLUME=/opt/seadoc-data - -ENABLE_SEADOC=false -SEADOC_SERVER_URL=http://example.seafile.com/sdoc-server - -NOTIFICATION_SERVER_IMAGE=seafileltd/notification-server:12.0-latest -NOTIFICATION_SERVER_VOLUME=/opt/notification-data diff --git a/seafile/docker-compose.yml b/seafile/docker-compose.yml deleted file mode 100644 index 7af56ee..0000000 --- a/seafile/docker-compose.yml +++ /dev/null @@ -1,56 +0,0 @@ -services: - db: - image: ${SEAFILE_DB_IMAGE:-mariadb:10.11} - container_name: seafile-mysql - environment: - - MYSQL_ROOT_PASSWORD=${INIT_SEAFILE_MYSQL_ROOT_PASSWORD:?Variable is not set or empty} - - MYSQL_LOG_CONSOLE=true - - MARIADB_AUTO_UPGRADE=1 - volumes: - - "${SEAFILE_MYSQL_VOLUME:-/opt/seafile-mysql/db}:/var/lib/mysql" - - healthcheck: - test: - [ - "CMD", - "/usr/local/bin/healthcheck.sh", - "--connect", - "--mariadbupgrade", - "--innodb_initialized", - ] - interval: 20s - start_period: 30s - timeout: 5s - retries: 10 - - seafile: - image: ${SEAFILE_IMAGE:-seafileltd/seafile-mc:12.0-latest} - container_name: seafile - ports: - - "8082:80" - volumes: - - ${SEAFILE_VOLUME:-/opt/seafile-data}:/shared - - /media/sync/seafile:/shared/seafile/seafile-data - environment: - - DB_HOST=${SEAFILE_MYSQL_DB_HOST:-db} - - DB_PORT=${SEAFILE_MYSQL_DB_PORT:-3306} - - DB_ROOT_PASSWD=${INIT_SEAFILE_MYSQL_ROOT_PASSWORD:-} - - DB_PASSWORD=${SEAFILE_MYSQL_DB_PASSWORD:?Variable is not set or empty} - - SEAFILE_MYSQL_DB_CCNET_DB_NAME=${SEAFILE_MYSQL_DB_CCNET_DB_NAME:-ccnet_db} - - SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=${SEAFILE_MYSQL_DB_SEAFILE_DB_NAME:-seafile_db} - - SEAFILE_MYSQL_DB_SEAHUB_DB_NAME=${SEAFILE_MYSQL_DB_SEAHUB_DB_NAME:-seahub_db} - - TIME_ZONE=${TIME_ZONE:-Etc/UTC} - - INIT_SEAFILE_ADMIN_EMAIL=${INIT_SEAFILE_ADMIN_EMAIL:-me@example.com} - - INIT_SEAFILE_ADMIN_PASSWORD=${INIT_SEAFILE_ADMIN_PASSWORD:-asecret} - - SEAFILE_SERVER_HOSTNAME=${SEAFILE_SERVER_HOSTNAME:?Variable is not set or empty} - - SEAFILE_SERVER_PROTOCOL=${SEAFILE_SERVER_PROTOCOL:-http} - - SITE_ROOT=${SITE_ROOT:-/} - - NON_ROOT=${NON_ROOT:-false} - - JWT_PRIVATE_KEY=${JWT_PRIVATE_KEY:?Variable is not set or empty} - - ENABLE_SEADOC=${ENABLE_SEADOC:-false} - - SEADOC_SERVER_URL=${SEADOC_SERVER_URL:-http://example.example.com/sdoc-server} - labels: - caddy: ${SEAFILE_SERVER_PROTOCOL:-http}://${SEAFILE_SERVER_HOSTNAME:?Variable is not set or empty} - caddy.reverse_proxy: "{{upstreams 80}}" - depends_on: - - db diff --git a/seafile/server/nginx/conf/seafile.nginx.conf b/seafile/server/nginx/conf/seafile.nginx.conf new file mode 100644 index 0000000..2a37a5d --- /dev/null +++ b/seafile/server/nginx/conf/seafile.nginx.conf @@ -0,0 +1,79 @@ +# -*- mode: nginx -*- +# Auto generated at 11/30/2024 22:39:05 +server { +listen 80; +server_name seafile.rik.veenboer.xyz; + + client_max_body_size 10m; + + location / { + proxy_pass http://127.0.0.1:8000/; + proxy_read_timeout 310s; + proxy_set_header Host $http_host; + proxy_set_header Forwarded "for=$remote_addr;proto=$scheme"; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Connection ""; + proxy_http_version 1.1; + + client_max_body_size 0; + access_log /var/log/nginx/seahub.access.log seafileformat; + error_log /var/log/nginx/seahub.error.log; + } + + location /seafhttp { + rewrite ^/seafhttp(.*)$ $1 break; + proxy_pass http://127.0.0.1:8082; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + client_max_body_size 0; + proxy_connect_timeout 36000s; + proxy_read_timeout 36000s; + proxy_request_buffering off; + access_log /var/log/nginx/seafhttp.access.log seafileformat; + error_log /var/log/nginx/seafhttp.error.log; + } + + location /notification/ping { + proxy_pass http://127.0.0.1:8083/ping; + access_log /var/log/nginx/notification.access.log seafileformat; + error_log /var/log/nginx/notification.error.log; + } + + location /notification { + proxy_pass http://127.0.0.1:8083/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + access_log /var/log/nginx/notification.access.log seafileformat; + error_log /var/log/nginx/notification.error.log; + } + + location /seafdav { + rewrite ^/seafdav$ /seafdav/ permanent; + } + + location /seafdav/ { + proxy_pass http://127.0.0.1:8080/seafdav/; + 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; + proxy_read_timeout 1200s; + client_max_body_size 0; + + access_log /var/log/nginx/seafdav.access.log seafileformat; + error_log /var/log/nginx/seafdav.error.log; + } + + location /:dir_browser { + # Logo of WebDAV + proxy_pass http://127.0.0.1:8080/:dir_browser; + } + + location /media { + root /opt/seafile/seafile-server-latest/seahub; + } + +} \ No newline at end of file diff --git a/seafile/server/seafile/conf/gunicorn.conf.py b/seafile/server/seafile/conf/gunicorn.conf.py new file mode 100644 index 0000000..f836499 --- /dev/null +++ b/seafile/server/seafile/conf/gunicorn.conf.py @@ -0,0 +1,16 @@ +import os + +daemon = True +workers = 5 + +# default localhost:8000 +bind = "127.0.0.1:8000" + +# Pid +pids_dir = '/opt/seafile/pids' +pidfile = os.path.join(pids_dir, 'seahub.pid') + +# for file upload, we need a longer timeout value (default is only 30s, too short) +timeout = 1200 + +limit_request_line = 8190 diff --git a/seafile/server/seafile/conf/seafdav.conf b/seafile/server/seafile/conf/seafdav.conf new file mode 100644 index 0000000..d221caa --- /dev/null +++ b/seafile/server/seafile/conf/seafdav.conf @@ -0,0 +1,4 @@ +[WEBDAV] +enabled = false +port = 8080 +share_name = /seafdav diff --git a/seafile/server/seafile/conf/seafevents.conf b/seafile/server/seafile/conf/seafevents.conf new file mode 100644 index 0000000..9f687d5 --- /dev/null +++ b/seafile/server/seafile/conf/seafevents.conf @@ -0,0 +1,22 @@ +[DATABASE] +type = mysql +host = seafile-mysql +port = 3306 +username = seafile +password = PASSWORD +name = seahub_db + +[SEAHUB EMAIL] +enabled = false + +## interval of sending Seahub email. Can be s(seconds), m(minutes), h(hours), d(days) +interval = 30m + +# Enable statistics +[STATISTICS] +enabled=false + +# Enable file history +[FILE HISTORY] +enabled = true +suffix = md,txt,doc,docx,xls,xlsx,ppt,pptx,sdoc,py diff --git a/seafile/server/seafile/conf/seafile.conf b/seafile/server/seafile/conf/seafile.conf new file mode 100644 index 0000000..2d016c0 --- /dev/null +++ b/seafile/server/seafile/conf/seafile.conf @@ -0,0 +1,11 @@ +[fileserver] +port = 8082 + +[database] +type = mysql +host = seafile-mysql +port = 3306 +user = seafile +password = PASSWORD +db_name = seafile_db +connection_charset = utf8 diff --git a/seafile/server/seafile/conf/seahub_settings.py b/seafile/server/seafile/conf/seahub_settings.py new file mode 100755 index 0000000..b90abf8 --- /dev/null +++ b/seafile/server/seafile/conf/seahub_settings.py @@ -0,0 +1,16 @@ +SECRET_KEY = "e$3$hp7u@1ba25kxxa46a7q+bc*3dfulsxhyq+nmap1f@me78$" +SERVICE_URL = "https://seafile.rik.veenboer.xyz" +CSRF_TRUSTED_ORIGINS = [SERVICE_URL] +DEBUG = False +TIME_ZONE = 'Europe/Amsterdam' +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'seahub_db', + 'USER': 'seafile', + 'PASSWORD': 'PASSWORD', + 'HOST': 'seafile-mysql', + 'PORT': '3306', + 'OPTIONS': {'charset': 'utf8mb4'}, + } +}