diff --git a/image/base/Dockerfile b/image/base/Dockerfile index 019327a..7d6846e 100644 --- a/image/base/Dockerfile +++ b/image/base/Dockerfile @@ -4,13 +4,18 @@ FROM phusion/baseimage:0.9.19 ENV UPDATED_AT 20161110 RUN apt-get update -qq && apt-get -qq -y install python2.7-dev memcached python-pip \ - python-setuptools python-imaging python-mysqldb python-memcache python-ldap \ - python-urllib3 sqlite3 nginx \ - vim htop net-tools psmisc git wget curl + python-setuptools python-imaging python-mysqldb python-memcache python-ldap \ + python-urllib3 sqlite3 nginx \ + vim htop net-tools psmisc git wget curl && \ + pip install -U wheel && pip install click termcolor prettytable colorlog -RUN pip install -U wheel && pip install click termcolor prettytable colorlog +COPY services /services -RUN mkdir /etc/service/memcached -ADD memcached.sh /etc/service/memcached/run +RUN mkdir -p /etc/service/memcached && \ + mv /services/memcached.sh /etc/service/memcached/run && \ + mkdir -p /etc/service/nginx && \ + rm -f /etc/nginx/sites-enabled/* /etc/nginx/conf.d/* && \ + mv /services/nginx.conf /etc/nginx/nginx.conf && \ + mv /services/nginx.sh /etc/service/nginx/run CMD ["/sbin/my_init", "--", "bash", "-l"] diff --git a/image/base/memcached.sh b/image/base/services/memcached.sh similarity index 100% rename from image/base/memcached.sh rename to image/base/services/memcached.sh diff --git a/image/base/services/nginx.conf b/image/base/services/nginx.conf new file mode 100644 index 0000000..1bab6b5 --- /dev/null +++ b/image/base/services/nginx.conf @@ -0,0 +1,26 @@ +daemon off; +user www-data; +worker_processes auto; + +events { + worker_connections 768; +} + +http { + include /etc/nginx/mime.types; + server_names_hash_bucket_size 256; + server_names_hash_max_size 1024; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log info; + + gzip on; + gzip_types text/plain text/css application/javascript application/json text/javascript; + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; +} diff --git a/image/base/services/nginx.sh b/image/base/services/nginx.sh new file mode 100755 index 0000000..61e04b9 --- /dev/null +++ b/image/base/services/nginx.sh @@ -0,0 +1,3 @@ +#!/bin/sh +exec 2>&1 +exec /usr/sbin/nginx diff --git a/image/seafile/Dockerfile b/image/seafile/Dockerfile index 3b4b415..e8d0cfc 100644 --- a/image/seafile/Dockerfile +++ b/image/seafile/Dockerfile @@ -11,4 +11,6 @@ RUN mkdir -p /opt/seafile/ && \ RUN mkdir -p /etc/my_init.d ADD create_data_links.sh /etc/my_init.d/create_data_links.sh +ADD seafile.nginx.conf /etc/nginx/sites-enabled/seafile.nginx.conf + CMD ["/sbin/my_init", "--", "bash", "-l"] diff --git a/image/seafile/seafile.nginx.conf b/image/seafile/seafile.nginx.conf new file mode 100644 index 0000000..97368b8 --- /dev/null +++ b/image/seafile/seafile.nginx.conf @@ -0,0 +1,50 @@ +server { + listen 80; + server_name _ default_server; + + client_max_body_size 10m; + + location / { + proxy_pass http://127.0.0.1:8000/; + proxy_read_timeout 310s; + proxy_set_header Host $host; + proxy_set_header Forwarded "for=$remote_addr;proto=$scheme"; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Connection ""; + proxy_http_version 1.1; + } + + location /seafhttp { + rewrite ^/seafhttp(.*)$ $1 break; + proxy_pass http://127.0.0.1:8082; + client_max_body_size 0; + proxy_connect_timeout 36000s; + proxy_read_timeout 36000s; + } + + location /seafdav { + client_max_body_size 0; + fastcgi_pass 127.0.0.1:8080; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_script_name; + + fastcgi_param SERVER_PROTOCOL $server_protocol; + fastcgi_param QUERY_STRING $query_string; + fastcgi_param REQUEST_METHOD $request_method; + fastcgi_param CONTENT_TYPE $content_type; + fastcgi_param CONTENT_LENGTH $content_length; + fastcgi_param SERVER_ADDR $server_addr; + fastcgi_param SERVER_PORT $server_port; + fastcgi_param SERVER_NAME $server_name; + + access_log /var/log/nginx/seafdav.access.log; + error_log /var/log/nginx/seafdav.error.log; + } + + location /media { + root /opt/seafile/seafile-server-latest/seahub; + autoindex off; + } +} diff --git a/launcher b/launcher index dd06fac..ea0983a 100755 --- a/launcher +++ b/launcher @@ -5,7 +5,7 @@ set -o pipefail version=6.0.5 image=seafileorg/server:$version -dockerdir=$(cd $(dirname $0); pwd -P) +dockerdir=$(cd "$(dirname $0)"; pwd -P) sharedir=$dockerdir/shared installdir=/opt/seafile/seafile-server-$version @@ -25,6 +25,8 @@ err_and_quit () { init_shared() { mkdir -p $sharedir/seafile/ mkdir -p $sharedir/logs/{seafile,var-log} + + mkdir -p $sharedir/logs/var-log/nginx touch $sharedir/logs/var-log/syslog local bash_history=$sharedir/.bash_history @@ -53,13 +55,17 @@ set_volumes() { } bootstrap() { + local bootstrap_conf=$dockerdir/bootstrap/bootstrap.conf + if [[ ! -e $bootstrap_conf ]]; then + err_and_quit "The file $bootstrap_conf doesn't exist. Have you run seafile-server-setup?" + fi set_volumes docker run --rm -it -e SEAFILE_BOOTSRAP=1 $volumes $image /scripts/bootstrap.py } start() { set_volumes - docker run --rm -it $volumes $image /scripts/start.py + docker run --rm -it --name seafile $volumes $image # /scripts/start.py } enter() {