code-of-kpp / docker-seafile

Seafile docker image
9 stars 2 forks source link

Seafile docker image

Run manually

First, you need to run mariadb or mysql image:

docker run \
    --name seafile-mariadb \
    -v /$SOME_ABS_PATH/maria-seafile:/var/lib/mysql \
    -e MYSQL_ROOT_PASSWORD=thisisabsolutlyinsecure \
    -e MYSQL_USER=seafile \
    -e MYSQL_PASSWORD=everybodyknowsthat \
    -d mariadb:latest

Run this image

docker run \
   --name seafile \
   -v /$SOME_ABS_PATH/seafile-data:/seafile-data/ \
   -p 80:8000 -p 8082:8082 -p 8080:8080 -p 10001:10001 -p 12001:12001 \
   --link seafile-mariadb:db \
   -e SITE_BASE=http://127.0.0.1 \
   -d podshumok/seafile

Run with nginx

  1. Run this image with -e SEAFILE_FASTCGI_HOST=0.0.0.0:

    docker run \
        --name seafile \
        -v /$SOME_ABS_PATH/seafile-data:/seafile-data/ \
        -p 10001:10001 -p 12001:12001 \
        --link seafile-mariadb:db \
        -e SITE_BASE=http://127.0.0.1 \
        -e SEAFILE_FASTCGI_HOST=0.0.0.0 \
        -d podshumok/seafile
  2. Create /$SOME_ABS_PATH/conf.d/default.conf (nginx configuration file):

    mkdir -p /$SOME_ABS_PATH/conf.d
    wget https://github.com/podshumok/docker-seafile/raw/master/conf.d/default.conf \
        -O /$SOME_ABS_PATH/conf.d/default.conf
  3. Run nginx image:

    docker run \
        --name seafile-nginx \
        -p 80:80 \
        --link seafile:seafile \
        -v /$SOME_ABS_PATH/conf.d:/etc/nginx/conf.d \
        -v /$SOME_ABS_PATH/nginxlog:/var/log/nginx \
        -v /$SOME_EMPTY_DIR:/etc/nginx/sites-enabled \
        -v /$SOME_EMPTY_DIR:/etc/nginx/certs \
        -v /$SOME_EMPTY_DIR:/var/www/html \
        -d nginx

Run seafile with docker-compose

Create project tree:

seafile/
|--- conf.d/
|----|--- default.conf  # nginx configuration file
|----ssl/               # (optional)
|----|--- seafile.crt   # your cacert.pem
|----|--- seafile.key   # your privkey.pem
|--- data/
|--- docker-compose.yml

Template for conf.d/default.conf is here. If you need HTTPS replace listen 80; with listen 443 ssl; and add ssl_certificate and ssl_certificate_key e.g.:

server {
    listen 443 ssl;
    ssl_certificate         certs/seafile.crt;
    ssl_certificate_key     certs/seafile.key;
    ...

docker-compose.yml sketch:

mariadb:
  image: mariadb:latest
  volumes:
    - ./data/maria:/var/lib/mysql
    - ./data/log/maria:/var/log/mysql
  environment:
    - MYSQL_ROOT_PASSWORD=pleasechangeitorelse
    - MYSQL_USER=seafile
    - MYSQL_PASSWORD=thisoneshouldbechangedtoo

seafile:
  image: podshumok/seafile
  volumes:
    - ./data/seafile:/seafile-data/
    - ./data/log/seafile:/var/log/seafile
  links:
    - mariadb:db
  environment:
    # replace http:// with https:// for SSL configuration
    - SITE_BASE=http://127.0.0.1
    - SEAFILE_FASTCGI_HOST=0.0.0.0

nginx:
  image: nginx
  ports:
    - "443:443"
  links:
    - seafile
  volumes:
    - ./conf.d:/etc/nginx/conf.d:ro
    - ./ssl:/etc/nginx/certs:ro
    - ./data/log/nginx:/var/log/nginx
    - /tmp/empty:/etc/nginx/sites-enabled:ro
    - /tmp/empty:/var/www/html:ro

Now just run docker-compose up in the project root.

Environment variables