Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maintain rclone #6

Merged
merged 23 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 88 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ Polyfiller is kindly supported by [JetBrains](https://www.jetbrains.com/?from=Po
- [What's the difference from polyfill.io](#whats-the-difference-from-polyfillio)
- [Hosting](#hosting)
- [Docker](#docker)
- [Install Docker in Cloud Server at first](#install-docker-in-cloud-server-at-first)
- [Simple container](#simple-container)
- [Composed services with Object Storage](#composed-services-with-object-storage)
- [1. Manual deployment](#1-manual-deployment)
- [1. Rclone config](#1-rclone-config)
- [2. Automatic deployment](#2-automatic-deployment)
- [Logo](#logo)
- [License](#license)
Expand Down Expand Up @@ -371,6 +372,54 @@ If you use a load balancer and something like `nginx` in a reverse proxy setup,

> This guide has been tested in the deployment process of China mirror: https://polyfiller.kaiyuanshe.cn

##### Install Docker in Cloud Server at first

In the development environment, use installation script

```shell
curl -fsSL https://get.docker.com | sudo sh
```

add the current user to the `docker` user group

```shell
sudo gpasswd -a ${USER} docker
```

You need to press <kbd>CTRL</kbd> + <kbd>D</kbd> to log out of the session, then use SSH to log back into the system.

[Docker-install-script](https://github.com/docker/docker-install) says `It is not recommended to depend on this script for deployment to production systems`.
**So depend on your choice**.
Find more information in the [Docker install document](https://docs.docker.com/engine/install/).

Rclone use `FUSE` mount the Rclone's cloud storage systems, you need to install it.

In Debian(Ubuntu)

```shell
sudo apt install fuse3 -y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有没有 Linux 通用 shell 安装脚本?

```

In CentOS

```shell
sudo yum install epel-release
sudo yum update
sudo yum install fuse3
```

In Fedora

```shell
sudo dnf install fuse3
```

In Arch

```shell
sudo pacman -Syu fuse3
```

##### Simple container

Run shown commands in the Project Root folder:
Expand All @@ -382,28 +431,55 @@ docker run --name polyfiller -e NODE_ENV=production -p 3000:3000 polyfiller/api-

##### Composed services with Object Storage

Install Docker plugins in Cloud Server at first:
###### 1. Rclone config

```shell
sudo apt install docker-compose
sudo docker plugin install juicedata/juicefs
1. Write [Rclone config](https://rclone.org/install/) into `config/rclone/rclone.conf` file of your Project:

```ini
[azure]
type = azureblob
account = xxxx
key = xxxx
endpoint = https://xxx
```

###### 1. Manual deployment
How to configure quickly? Use `rclone config` command? It needs to know a lot of things. Open [Document](https://rclone.org/docs/), choose an instructions, like [Dropbox](https://rclone.org/dropbox/).

1. Write [JuiceFS object storage variables](https://juicefs.com/docs/community/reference/how_to_set_up_object_storage/) into `.env` file in the Project Root folder:
Look for

```ini
STORAGE_TYPE =
BUCKET =
ACCESS_KEY =
SECRET_KEY =
[remote]
app_key =
app_secret =
token = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX_XXXX_XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

It is the configuration for Dropbox.

```ini
[dropbox]
type = dropbox
app_key = xxxxxxxxx
app_secret = xxxxxxxxx
token = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX_XXXX_XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

If you use Dropbox, in `docker-compose.yml`:

```yaml
command: "mount azure:/ /polyfill-cache --allow-other --allow-non-empty --vfs-cache-mode writes"
```

It should be changed to:

```yml
command: "mount dropbox:/ /polyfill-cache --allow-other --allow-non-empty --vfs-cache-mode writes"
```

2. Run shown commands in the Project Root folder:

```shell
docker-compose up -d
docker compose up -d
```

###### 2. Automatic deployment
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
restart: always

meta-server:
polyfill-cache:
image: rclone/rclone:latest
environment:
- RCLONE_CONFIG=/config/rclone/rclone.conf # Path to the rclone config file inside the container
Expand All @@ -30,7 +30,7 @@ services:
api-service:
depends_on:
- autoheal
- meta-server
- polyfill-cache
image: polyfiller/api-service
environment:
- NODE_ENV=production
Expand Down
9 changes: 6 additions & 3 deletions start-docker.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#! /usr/bin/env bash

docker load < $1
docker load <$1
docker image ls -a

docker-compose down -v --remove-orphans
docker-compose up -d
# umount polyfill-cache dir
sudo umount "$(pwd)/polyfill-cache" || true

docker compose down -v --remove-orphans
docker compose up -d

docker image prune -a -f