Ver código fonte

Add Dockerfile for Seafile Pro

dennisro 7 anos atrás
pai
commit
845c9b4185

+ 53 - 0
data/Dockerfiles/seafilepro/Dockerfile

@@ -0,0 +1,53 @@
+FROM phusion/baseimage:0.9.22
+
+MAINTAINER Dennis Rodewyk <ufo@chaosbunker.com>
+
+ENV SEAFILE_VERSION 6.2.13
+EXPOSE 80
+
+VOLUME /seafile
+WORKDIR /seafile
+
+# Required packages for pro edition
+RUN apt-get update && apt-get install -y \
+  openjdk-8-jre poppler-utils libpython2.7 python-pip \
+  python-setuptools python-imaging python-mysqldb python-memcache python-ldap \
+  python-urllib3 wget nginx \
+  libreoffice libreoffice-script-provider-python fonts-vlgothic ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy && pip install boto
+
+# Download seafile binary
+RUN wget "https://download.seafile.com/d/6e5297246c/files/?p=/pro/seafile-pro-server_${SEAFILE_VERSION}_x86-64.tar.gz&dl=1" -O "/seafile-pro-server_${SEAFILE_VERSION}_x86-64.tar.gz"
+
+# Install Seafile service.
+ADD service/seafile/run.sh /etc/service/seafile/run
+ADD service/seafile/stop.sh /etc/service/seafile/stop
+
+# Install Seahub service.
+ADD service/seahub/run.sh /etc/service/seahub/run
+ADD service/seahub/stop.sh /etc/service/seahub/stop
+
+# Install Ngninx service
+ADD service/nginx/run.sh /etc/service/nginx/run
+
+# Add custom configuration
+COPY config/seafevents.conf /seafevents.conf
+
+# Configure nginx
+COPY config/seafile.conf /etc/nginx/sites-available/seafile.conf
+RUN ln -s /etc/nginx/sites-available/seafile.conf /etc/nginx/sites-enabled/seafile.conf && \
+	rm /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
+
+# Clean up
+RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+
+ADD bin/setup.sh /usr/local/sbin/setup
+ADD bin/upgrade.sh /usr/local/sbin/upgrade
+
+# Set permissions
+RUN chmod +x /usr/local/sbin/setup && \
+	chmod +x /usr/local/sbin/upgrade && \
+	chmod +x /etc/service/seafile/* && \
+	chmod +x /etc/service/seahub/* && \
+	chmod +x /etc/service/nginx/*
+
+CMD /sbin/my_init

+ 9 - 0
data/Dockerfiles/seafilepro/README.md

@@ -0,0 +1,9 @@
+### How to upgrade:
+
+- Check new version in Dockerfile
+- `bash data/services/seafilepro/seafilepro.sh upgrade`
+- Enter new seafile version when asked
+- Confirm that you want to rebuild the image
+- When temporary upgrade container is running, press enter to run upgrade
+
+That's it.

+ 36 - 0
data/Dockerfiles/seafilepro/bin/setup.sh

@@ -0,0 +1,36 @@
+#!/bin/bash
+
+set -e
+
+if [ -f /seafile/.installed ];then
+	echo " Already installed."
+	exit
+fi
+
+# Get latest tarball and extract it
+cd /seafile
+
+echo "Extracting server binary ..."
+tar -xzf "/seafile-pro-server_${SEAFILE_VERSION}_x86-64.tar.gz"
+
+mkdir installed
+mv "/seafile-pro-server_${SEAFILE_VERSION}_x86-64.tar.gz" installed
+
+cd "/seafile/seafile-pro-server-${SEAFILE_VERSION}"
+
+# Setup seafile
+ulimit -n 30000
+./setup-seafile-mysql.sh
+
+# Custom configurations
+mkdir -p /seafile/conf
+echo "ENABLE_RESUMABLE_FILEUPLOAD = True" >> /seafile/conf/seahub_settings.py
+mv /seafevents.conf /seafile/conf/
+
+# Launch setup
+./seafile.sh start
+./seahub.sh start
+./seafile.sh stop
+./seahub.sh stop
+
+touch /seafile/.installed

+ 67 - 0
data/Dockerfiles/seafilepro/bin/upgrade.sh

@@ -0,0 +1,67 @@
+#!/bin/bash
+
+cd /seafile
+
+echo "Checking if Seafile is installed ..."
+if [ ! -d "/seafile/seafile-server-latest" ]; then
+	echo "[FAILED] Seafile is not installed!"
+	exit 0
+fi
+
+# Get version based on the seafile-server-latest symbolic link that is pointing to the current installation.
+CURRENT_VERSION=$(ls -lah | grep 'seafile-server-latest' | awk -F"seafile-pro-server-" '{print $2}')
+NEW_VERSION=$1
+
+if [ "$CURRENT_VERSION" == "$NEW_VERSION" ]; then
+	echo "[FAILED] You already have the most recent version installed"
+	exit 0
+else
+	echo "Downloading seafile-pro-server_${NEW_VERSION}_x86-64.tar.gz"
+	if [ ! -f /seafile-pro-server_${NEW_VERSION}_x86-64.tar.gz ];then
+		wget "https://download.seafile.com/d/6e5297246c/files/?p=/pro/seafile-pro-server_${NEW_VERSION}_x86-64.tar.gz&dl=1" -O "/seafile-pro-server_${NEW_VERSION}_x86-64.tar.gz" 2>/dev/null
+	fi
+fi
+
+echo "Extracting server binary ..."
+tar -xzf "/seafile-pro-server_${NEW_VERSION}_x86-64.tar.gz" 2>/dev/null
+if [[ $? != 0 ]];then
+	echo "Could not extract server binary. Are you sure $NEW_VERSION is a valid version number?"
+	rm /seafile-pro-server_${NEW_VERSION}_x86-64.tar.gz
+	exit 1
+fi
+mv "/seafile-pro-server_${NEW_VERSION}_x86-64.tar.gz" installed/
+
+cd "/seafile/seafile-pro-server-${NEW_VERSION}"
+
+# First we need to check if it's a maintenance update, since the process is different from a major/minor version upgrade
+CURRENT_MAJOR_VERSION=$(echo $CURRENT_VERSION | awk -F"." '{print $1}')
+CURRENT_MINOR_VERSION=$(echo $CURRENT_VERSION | awk -F"." '{print $2}')
+CURRENT_MAINTENANCE_VERSION=$(echo $CURRENT_VERSION | awk -F"." '{print $3}')
+
+NEW_MAJOR_VERSION=$(echo $NEW_VERSION | awk -F"." '{print $1}')
+NEW_MINOR_VERSION=$(echo $NEW_VERSION | awk -F"." '{print $2}')
+NEW_MAINTENANCE_VERSION=$(echo $NEW_VERSION | awk -F"." '{print $3}')
+
+if [ "$CURRENT_MAJOR_VERSION" == "$NEW_MAJOR_VERSION" ] && [ "$CURRENT_MINOR_VERSION" == "$NEW_MINOR_VERSION" ]; then
+  # Alright, this is only a maintenance update.
+  echo "Performing maintenance update ..."
+  ./upgrade/minor-upgrade.sh
+  cd /seafile
+  rm -rf "/seafile/seafile-pro-server-${CURRENT_VERSION}"
+else
+  # Big version jump (e.g. 6.1.x to 6.2.x)
+  for file in ./upgrade/upgrade_*.sh
+  do
+    UPGRADE_FROM=$(echo "$file" | awk -F"_" '{print $2}')
+    UPGRADE_TO=$(echo "$file" | awk -F"_" '{print $3}' | sed 's/\.sh//g')
+
+    if [ "$UPGRADE_FROM" == "$CURRENT_MAJOR_VERSION.$CURRENT_MINOR_VERSION" ]; then
+      echo "Upgrading from $UPGRADE_FROM to $UPGRADE_TO ..."
+      $file
+      CURRENT_MAJOR_VERSION=$(echo $UPGRADE_TO | awk -F"." '{print $1}')
+      CURRENT_MINOR_VERSION=$(echo $UPGRADE_TO | awk -F"." '{print $2}')
+    fi
+  done
+fi
+
+echo "All done! Bye."

+ 18 - 0
data/Dockerfiles/seafilepro/config/seafevents.conf

@@ -0,0 +1,18 @@
+[DATABASE]
+type = sqlite3
+path = /seafile/pro-data/seafevents.db
+
+
+
+[INDEX FILES]
+enabled = true
+interval = 10m
+index_office_pdf = true
+
+[OFFICE CONVERTER]
+enabled = true
+workers = 1
+
+[SEAHUB EMAIL]
+enabled = true
+interval = 30m

+ 39 - 0
data/Dockerfiles/seafilepro/config/seafile.conf

@@ -0,0 +1,39 @@
+server {
+    listen 80;
+
+    proxy_set_header X-Forwarded-For $remote_addr;
+
+    location / {
+        fastcgi_pass    127.0.0.1:8000;
+        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;
+        fastcgi_param   REMOTE_ADDR         $remote_addr;
+
+        access_log      /var/log/nginx/seahub.access.log;
+        error_log       /var/log/nginx/seahub.error.log;
+        fastcgi_read_timeout 36000;
+    }
+
+    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;
+        proxy_send_timeout  36000s;
+        send_timeout  36000s;
+    }
+
+    location /media {
+        root /seafile/seafile-server-latest/seahub;
+    }
+}

+ 3 - 0
data/Dockerfiles/seafilepro/service/nginx/run.sh

@@ -0,0 +1,3 @@
+#!/bin/sh
+
+/usr/sbin/nginx -g 'daemon off;'  >> /var/log/nginx.log 2>&1

+ 9 - 0
data/Dockerfiles/seafilepro/service/seafile/run.sh

@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -eu
+
+/seafile/seafile-server-latest/seafile.sh start >> /var/log/service-seafile.log
+
+while [ 1 ]; do
+  sleep 10
+done

+ 5 - 0
data/Dockerfiles/seafilepro/service/seafile/stop.sh

@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -eu
+
+/seafile/seafile-server-latest/seafile.sh stop

+ 9 - 0
data/Dockerfiles/seafilepro/service/seahub/run.sh

@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -eu
+
+/seafile/seafile-server-latest/seahub.sh start-fastcgi >> /var/log/service-seahub.log
+
+while [ 1 ]; do
+  sleep 10
+done

+ 5 - 0
data/Dockerfiles/seafilepro/service/seahub/stop.sh

@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -eu
+
+/seafile/seafile-server-latest/seahub.sh stop