As files in your devices increase, a common limitation is having a cloud storage to get your files securely stored and available for your access and collaboration. Common storage services (like Google Drive or One Drive) give you few space compared with modern needs and require a fee for bigger GigaBytes. Seafile with Raspberry PI can give a cheap solution with cross device clients
In this tutorial, I’m going to show you how to install and configure Seafile with Raspberry PI by using Docker, which makes far simpler the installation procedure.
What is Seafile
Seafile is an open-source file sync&share solution composed of server and client software. The server part makes your Seafile page available for access. In this tutorial, our Raspberry PI will run the server software. The client one lets you use Seafile from any external device. From clients, you can also use a simple web browser to explore your files and collaborate on them.
Seafile also adds a security layer to files stored on the server: they can be encrypted by a password chosen by you so that, also in case of external server hosting, even the system admin can’t view the files.
For this tutorial, I’m going to use a Raspberry PI 3 Model A+ computer board, but you can use these steps also with newer Raspberry PI computer boards.
If you need to access Seafile from the internet and you have a public IP to do this, you can use a No-IP free domain with my How to configure No-IP DUC service in your Raspberry PI, taking care to arrange the port forward in your home router for ports 80/443.
What We Need
As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if continue with the project or remove them from the shopping cart. So, hardware will be only:
- Raspberry PI 3 Model A+ (including proper power supply or using a smartphone micro usb charger with at least 3A) or newer Raspberry PI Board
- high speed micro SD card (at least 16 GB, at least class 10)
Check hardware prices with the following links:
Prepare Operating System
Start preparing your OS. Please note that we have to use a 64-bit OS in order to get MariaDB container directly available from Docker. Otherwise, we’ll need to modify our docker-compose file according to my Create a Custom MariaDB Container with Raspberry PI and Docker tutorial.
You can install Raspberry PI OS Lite (to get a faster, headless OS) or you can install Raspberry PI OS Desktop, in this case working from its internal terminal. For low ram Raspberry PI computer models, the Lite OS is strongly suggested.
A few more optimizations can be performed, expecially for Lite installations in RPI boards with RAM lower tha 1GB:
- reduce GPU to 16MB > Manage Raspberry PI GPU Memory Split
- Change Swap File to 1000MB > Set Raspberry PI Swap Memory
Make sure that your OS is updated. From terminal:
sudo apt update -y && sudo apt upgrade -y
Finally, install docker and docker-compose with the following tutorial: Setup a Docker environment with Raspberry PI OS Lite. The Portainer installation is not strictly required, but it is a good tool to try in order to manage your Docker environment.
With docker and docker-compose available in your Raspberry PI, the Seafile installation becomes really simple. Please create a new folder in your Raspberry PI. This will include the docker-compose file. Consider that the containers created will take name prefix from this folder name, so I will use “Seafile” but you can use whatever name you prefer:
mkdir Seafile cd Seafile
You can both get my docker-compose.yml template for Seafile with the following terminal command:
or you can create it manually:
by pasting the following content inside it:
version: '2.0' services: db: image: mariadb:10.5 container_name: seafile-mysql environment: - MYSQL_ROOT_PASSWORD=db_pwd - MYSQL_LOG_CONSOLE=true volumes: - /opt/seafile-mysql/db:/var/lib/mysql networks: - seafile-net memcached: image: memcached:1.5.6 container_name: seafile-memcached entrypoint: memcached -m 256 networks: - seafile-net seafile: image: seafileltd/seafile-mc:latest container_name: seafile ports: - "80:80" # - "443:443" # If https is enabled, cancel the comment. volumes: - /opt/seafile-data:/shared environment: - DB_HOST=db - DB_ROOT_PASSWD=db_pwd - TIME_ZONE=Europe/Rome - SEAFILE_ADMIN_EMAILemail@example.com - SEAFILE_ADMIN_PASSWORD=my_pwd - SEAFILE_SERVER_LETSENCRYPT=false - SEAFILE_SERVER_HOSTNAME=192.168.1.177 depends_on: - db - memcached networks: - seafile-net networks: seafile-net:
Before saving and closing, please edit at least the parts highlighted in red according to your preferences:
- db_pwd: this sets the MariaDB database password for root access (first occurrence) and the password that Seafile container will use to access the DB (second occurrence). Both occurrences must have same value
- TIME_ZONE=Europe/Rome: this sets the timezone for Seafile. You can get a list of timezones with correct strings with the following Wikipedia link: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
- firstname.lastname@example.org / my_pwd: these strings set the administrator account username and password to access the Seafile console. With these credentials, you can create new users and modify the Seafile server settings
- SEAFILE_SERVER_LETSENCRYPT=false: this disables or enables https secure protocol. With “false” value, you can access seafile by using “http”. WIth “true”, you can use “https” access but you need to have a public IP address and domain to do it.
- SEAFILE_SERVER_HOSTNAME=192.168.1.177: this sets the Seafile access IP or domain. If you have a domain, use it instead of IP address. If you don’t have a domain, you can use your Raspberry PI’s IP address. The 192.168.1.177 is my RPI IP in my local network, so change this with your one.
Also note that this docker-compose configuration maps persistent volumes to your Raspberry PI storage in order to keep them saved even when containers are removed. These volumes will ve available in your /opt/ folder and will include the Seafile files (/opt/seafile-data/) and database files (/opt/seafile-mysql/). You can map these volumes to external storage to get more space, keeping care to make the external volume mounting always with the same path over reboots.
Once set and customized, save and close the docker-compose.yml file and Seafile can be completely installed with the following terminal command (run inside the “Seafile” folder):
docker-compose up -d
Wait for your RPI to download all the required docker images, it can take minutes depending also on your internet speed. When the terminal prompt comes back to you, you can check that all the containers are correctly running with the “docker ps -a” command:
pi@raspberrypi:~/Seafile $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 764220fde392 seafileltd/seafile-mc:latest "/sbin/my_init -- /s…" About a minute ago Up About a minute 0.0.0.0:80->80/tcp seafile 8babbe34b8fc memcached:1.5.6 "memcached -m 256" 2 minutes ago Up About a minute 11211/tcp seafile-memcached f7dfbdc6327d mariadb:10.5 "docker-entrypoint.s…" 2 minutes ago Up About a minute 3306/tcp seafile-mysql
With low-grade Raspberry PI computers, the Seafile initialization can take a few more seconds. You can check if Seafile is ready and running by periodically issuing the docker command to inspect containers logs:
docker logs seafile
The following result will say you that Seafile is ready:
... ... Seafile server started Done. Starting seahub at port 8000 ... ---------------------------------------- Successfully created seafile admin ---------------------------------------- Seahub is started Done.
From your local computer, use your favourite browser to access Seafile by using your domain or Raspberry PI’s IP:
Please use the credentials set in your docker-compose.yml to access:
As you can see, a default library is already available for the very first tests. From the user menu you can both access the user Settings and the server administration page (System Admin):
By selecting the System Admin menu you will be able, besides other things, to manually add users
But you can also allow users to self-register in your Seafile installation. To do this, please select “Setting” in the left sidebar menu (still in “System Admin”) and scroll down to activate the “allow new registration” option. A good way to manage user’s activation is by sending them the “activation email”. You can activate also this option, but the email configuration is not still ready (I’ll show you in next step how to configure it):
Please note that the “allow new registrations” will enable a Signup link in Seafile login page:
Configure Seafile Email Sending with Gmail
Sending email from Seafile require an existing email account from an internet provider. As one of the most common is Google with its Gmail services, in this step we’ll use an existing Gmail account.
Because of Google security restrictions, you can’t use directly your Gmail address and password. So, before taking the next actions, do the following:
- go to your google account (https://myaccount.google.com/)
- Select Security
- Under “Signing in to Google,” select App Passwords
- At the bottom, choose Select app and choose Email and then select “Other” as device. Give a mnemonic name for this password app (for example “Seafile”) and then press Generate
- The password we’ll get is the 16-character code in the yellow bar. Please take note of it
- Click Done
With the app password generated, edit from your Raspberry PI terminal the Seahub settings file:
sudo nano /opt/seafile-data/seafile/conf/seahub_settings.py
append the following content at the end by editing only the values highlighted in red:
EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'email@example.com' EMAIL_HOST_PASSWORD = 'my_google_app_password' EMAIL_PORT = 587 DEFAULT_FROM_EMAIL = EMAIL_HOST_USER SERVER_EMAIL = EMAIL_HOST_USER
Save and close. With the terminal still in your Seafile folder from Raspberry PI, please issue the following command:
This will restart your Seafile installation also keeping the new configuration but maintaining the old files as they are stored in the (persistent) volumes created with docker-compose file. The same command can be used for whatever change you need to do in your Seafile settings.
The “docker logs seafile” command will allow you to check that everything went good and you can test it.
For our test, you can
- go to your Seafile home page
- enter the default library (My Library)
- press the share button appearing when moving the mouse on “seafile-tutorial.doc”
- In the next view, click directly the “Send” button
- Fill the recipient(s) email address and the message fields
- Click “Send”
The recipient(s) will receive an email like the following one:
Seafile Manual Pages
More customization settings can be found on the official Seafile server manual page.
Interested in more projects for your RPI? Take a look at peppe8o Raspberry PI computers tutorial!
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?