Skip to content

Commit

Permalink
Merge pull request #334 from haiwen/12.0_update_101124
Browse files Browse the repository at this point in the history
feat: 12.0 support version control
  • Loading branch information
freeplant authored Oct 11, 2024
2 parents 28c0873 + 3f5d0b5 commit 192acf8
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 818 deletions.
211 changes: 42 additions & 169 deletions manual/docker/deploy_seafile_with_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,50 @@ The following assumptions and conventions are used in the rest of this document:

Use the [official installation guide for your OS to install Docker](https://docs.docker.com/engine/install/).

### Download and modify `docker-compose.yml`
### Download and modify `.env`

Download the `docker-compose.yml` sample file into Seafile's directory and modify the Compose file to fit your environment and settings.
From Seafile Docker 12.0, we recommend that you use `.env`, `seafile-server.yml` and `caddy.yml` files for configuration.

**NOTE:** Different versions of Seafile have different compose files.

```bash
mkdir /opt/seafile
cd /opt/seafile

# Seafile CE 10.0
wget -O "docker-compose.yml" "https://manual.seafile.com/docker/docker-compose/ce/10.0/docker-compose.yml"
# Seafile CE 12.0
wget -O .env https://manual.seafile.com/docker/docker-compose/ce/12.0/env
wget https://manual.seafile.com/docker/docker-compose/ce/12.0/seafile-server.yml
wget https://manual.seafile.com/docker/docker-compose/ce/12.0/caddy.yml

# Seafile CE 11.0
wget -O "docker-compose.yml" "https://manual.seafile.com/docker/docker-compose/ce/11.0/docker-compose.yml"

nano docker-compose.yml
nano .env
```

The following fields merit particular attention:

* The password of MySQL root (`MYSQL_ROOT_PASSWORD` and `DB_ROOT_PASSWD`)
* The volume directory of MySQL data (volumes)
* The volume directory of Seafile data (volumes).
- `SEAFILE_VOLUMES`: The volume directory of Seafile data
- `SEAFILE_MYSQL_VOLUMES`: The volume directory of MySQL data
- `SEAFILE_CADDY_VOLUMES`: The volume directory of Caddy data
- `SEAFILE_MYSQL_ROOT_PASSWORD`: The user `root` password of MySQL
- `SEAFILE_MYSQL_DB_PASSWORD`: The user `seafile` password of MySQL
- `JWT`: JWT_PRIVATE_KEY, A random string with a length of no less than 32 characters, generate example: `pwgen -s 40 1`
- `SEAFILE_SERVER_HOSTNAME`: Seafile server hostname or domain
- `SEAFILE_SERVER_PROTOCOL`: Seafile server protocol (http or https)
- `TIME_ZONE`: Time zone (default UTC)
- `SEAFILE_ADMIN_EMAIL`: Admin username
- `SEAFILE_ADMIN_PASSWORD`: Admin password

NOTE: SSL is now handled by the caddy server.

### Start Seafile server

Start Seafile server with the following command

```bash
# if `docker-compose.yml` file is in current directory:
docker-compose up -d
# if `.env` file is in current directory:
docker compose up -d

# if `docker-compose.yml` file is elsewhere:
docker-compose -f /path/to/docker-compose.yml up -d
# if `.env` file is elsewhere:
docker compose -f /path/to/.env up -d
```

Wait for a few minutes for the first time initialization, then visit `http://seafile.example.com` to open Seafile Web UI.
Expand All @@ -61,144 +70,47 @@ Placeholder spot for shared volumes. You may elect to store certain persistent i
* /opt/seafile-data/seafile/logs: This is the directory that would contain the log files of seafile server processes. For example, you can find seaf-server logs in `/opt/seafile-data/seafile/logs/seafile.log`.
* /opt/seafile-data/logs: This is the directory for operating system and Nginx logs.
* /opt/seafile-data/logs/var-log: This is the directory that would be mounted as `/var/log` inside the container. For example, you can find the nginx logs in `/opt/seafile-data/logs/var-log/nginx/`.
* /opt/seafile-data/ssl: This is directory for certificate, which does not exist by default.

### Find logs

To monitor container logs (from outside of the container), please use the following commands:

```bash
# if the `docker-compose.yml` file is in current directory:
# if the `.env` file is in current directory:
docker compose logs --follow
# if the `docker-compose.yml` file is elsewhere:
docker compose -f /path/to/docker-compose.yml logs --follow
# if the `.env` file is elsewhere:
docker compose -f /path/to/.env logs --follow

# you can also specify container name:
docker compose logs seafile --follow
# or, if the `docker-compose.yml` file is elsewhere:
docker compose -f /path/to/docker-compose.yml logs seafile --follow
# or, if the `.env` file is elsewhere:
docker compose -f /path/to/.env logs seafile --follow
```

The Seafile logs are under `/shared/logs/seafile` in the docker, or `/opt/seafile-data/logs/seafile` in the server that run the docker.

The system logs are under `/shared/logs/var-log`, or `/opt/seafile-data/logs/var-log` in the server that run the docker.

To monitor all Seafile logs simultaneously (from outside of the container), run

```bash
sudo tail -f $(find /opt/seafile-data/ -type f -name *.log 2>/dev/null)
```

## More configuration options

### Custom admin username and password

The default admin account is `[email protected]` and the password is `asecret`. You can use a different password by setting the container's environment variables in the `docker-compose.yml`:
e.g.

```yml
seafile:
...

environment:
...
- [email protected]
- SEAFILE_ADMIN_PASSWORD=a_very_secret_password
...

```

### Let's Encrypt SSL certificate

If you set `SEAFILE_SERVER_LETSENCRYPT` to `true`, the container would request a letsencrypt-signed SSL certificate for you automatically.

e.g.

```yml
seafile:
...
ports:
- "80:80"
- "443:443"
...
environment:
...
- SEAFILE_SERVER_LETSENCRYPT=true
- SEAFILE_SERVER_HOSTNAME=seafile.example.com
...

```

Since version 10.0.x, if you want to use a reverse proxy and apply for a certificate outside docker, you can use `FORCE_HTTPS_IN_CONF` to force write `https://<your_host>` in the configuration file.

e.g.

```yml
seafile:
...
environment:
...
- SEAFILE_SERVER_LETSENCRYPT=false
- SEAFILE_SERVER_HOSTNAME=seafile.example.com
- FORCE_HTTPS_IN_CONF=true
...

```

If you want to use your own SSL certificate, you can mount the certificate into the docker container by setting the container's volumes variables in the `docker-compose.yml`.

⚠️ Assuming your site name is `seafile.example.com`, then your certificate must have the name `seafile.example.com.crt`, and the private key must have the name `seafile.example.com.key` in container.

e.g.

```yml
seafile:
...
ports:
- "80:80"
- "443:443"
...
volumes:
...
- /etc/letsencrypt/live/seafile.example.com/fullchain.pem:/shared/ssl/seafile.example.com.crt
- /etc/letsencrypt/live/seafile.example.com/privkey.pem:/shared/ssl/seafile.example.com.key
environment:
...
- SEAFILE_SERVER_LETSENCRYPT=false
- SEAFILE_SERVER_HOSTNAME=seafile.example.com
- FORCE_HTTPS_IN_CONF=true
...
...
```

### Use an existing mysql-server

If you want to use an existing mysql-server, you can modify the `docker-compose.yml` as follows

```yml
services:
#db:
#image: mariadb:10.11
#...

seafile:
...
environment:
...
- DB_HOST=192.168.0.2
- DB_PORT=3306
- DB_ROOT_PASSWD=mysql_root_password
...
depends_on:
#- db
- memcached
If you want to use an existing mysql-server, you can modify the `.env` as follows

```env
SEAFILE_MYSQL_DB_HOST=192.168.0.2
SEAFILE_MYSQL_DB_PORT=3306
SEAFILE_MYSQL_ROOT_PASSWORD=ROOT_PASSWORD
SEAFILE_MYSQL_DB_PASSWORD=PASSWORD
```

* The entire db chapter needs to be removed
* The host of MySQL (`DB_HOST`)
* The port of MySQL (`DB_PORT`)
* The password of MySQL root (`DB_ROOT_PASSWD`)
* db in depends_on chapter needs to be removed
* `DB_ROOT_PASSWD` is needed during installation. Later, after Seafile is installed, the user `seafile` will be used to connect to the mysql-server (in `conf/seafile.conf`). You can remove the `DB_ROOT_PASSWD`.
NOTE: `SEAFILE_MYSQL_ROOT_PASSWORD` is needed during installation. Later, after Seafile is installed, the user `seafile` will be used to connect to the mysql-server (SEAFILE_MYSQL_DB_PASSWORD). You can remove the `SEAFILE_MYSQL_ROOT_PASSWORD`.

### Modify Seafile server configurations

Expand All @@ -222,18 +134,12 @@ Enter the username and password according to the prompts. You now have a new adm

### Run Seafile as non root user inside docker

Since version 10.0, you can use run seafile as non root user in docker. (**NOTE:** Programs such as `my_init`, Nginx are still run as `root` inside docker.)
You can use run seafile as non root user in docker. (**NOTE:** Programs such as `my_init`, Nginx are still run as `root` inside docker.)

First add the `NON_ROOT=true` to the `docker-compose.yml`.

```yml
seafile:
...
environment:
...
- NON_ROOT=true
...
First add the `NON_ROOT=true` to the `.env`.

```env
NON_ROOT=true
```

Then modify `/opt/seafile-data/seafile/` permissions.
Expand All @@ -242,16 +148,6 @@ Then modify `/opt/seafile-data/seafile/` permissions.
chmod -R a+rwx /opt/seafile-data/seafile/
```

Note: Before version 11.0.9, you have to create a seafile user on the host, and modify the owner to seafile in `/opt/seafile-data/seafile/`. (**NOTE:** Do not change the `uid` and `gid`.)

```bash
groupadd --gid 8000 seafile
useradd --home-dir /home/seafile --create-home --uid 8000 --gid 8000 --shell /bin/sh --skel /dev/null seafile
chown -R seafile:seafile /opt/seafile-data/seafile/
```

Then destroy the containers and run them again:

```bash
Expand All @@ -271,29 +167,6 @@ When files are deleted, the blocks comprising those files are not immediately re

The required scripts can be found in the `/scripts` folder of the docker container. To perform garbage collection, simply run `docker exec seafile /scripts/gc.sh`. For the community edition, this process will stop the seafile server, but it is a relatively quick process and the seafile server will start automatically once the process has finished. The Professional supports an online garbage collection.

## Deploy Seafile docker with custom port

Assume your custom port is 8001, when it is a new installation, you only need to modify the `docker-compose.yml` and start the Seafile docker.

```yml
seafile:
...
ports:
- "8001:80"
environment:
...
- SEAFILE_SERVER_HOSTNAME=seafile.example.com:8001
...
...
```

If you have installed the Seafile docker, besides modifying the `docker-compose.yml`, you also need to modify the already generated configuration file `conf/seahub_settings.py`, then restart Seafile:

```py
SERVICE_URL = "http://seafile.example.com:8001"
FILE_SERVER_ROOT = "http://seafile.example.com:8001/seafhttp"
```

## FAQ

### You can run docker commands like `docker exec` to find errors
Expand Down
Loading

0 comments on commit 192acf8

Please sign in to comment.