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 6 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
90 changes: 77 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ 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)
- [Simple container](#simple-container)
- [Composed services with Object Storage](#composed-services-with-object-storage)
- [Simple container](#simple-container)
- [1. Manual deployment](#1-manual-deployment)
- [2. Automatic deployment](#2-automatic-deployment)
- [Logo](#logo)
Expand Down Expand Up @@ -371,6 +371,57 @@ 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

##### Composed services with Object Storage

Install Docker in Cloud Server at first:

remove old Docker version
luojiyin1987 marked this conversation as resolved.
Show resolved Hide resolved

```shell
sudo apt remove -y docker docker-engine docker.io containerd runc
```

install dependencies

```shell
sudo apt install -y ca-certificates curl gnupg lsb-release
```

download GPG key and believe it

```shell
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
```

build source for the current CPU architecture and system version

```shell
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
```

install Docker-ce and Docker plugin

```shell
sudo apt update && sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
```

the current user joins the docker user group
luojiyin1987 marked this conversation as resolved.
Show resolved Hide resolved

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

You need to execute `CTRL+D` to log out of the session and use ssh to log back into the system.
luojiyin1987 marked this conversation as resolved.
Show resolved Hide resolved

Rclone use `FUSE` mount the Rclone's cloud storage systems, you need to install it.
```shell
sudo apt install fuse3 -y
luojiyin1987 marked this conversation as resolved.
Show resolved Hide resolved
```

##### Simple container

Run shown commands in the Project Root folder:
Expand All @@ -380,30 +431,43 @@ docker build -t polyfiller/api-service .
docker run --name polyfiller -e NODE_ENV=production -p 3000:3000 polyfiller/api-service
```

##### Composed services with Object Storage
###### 1. Manual deployment

Install Docker plugins in Cloud Server at first:
1. Write [rclone config](https://rclone.org/install/) into `rclone.conf` file in the Project `config/rclone` folder:
luojiyin1987 marked this conversation as resolved.
Show resolved Hide resolved

```shell
sudo apt install docker-compose
sudo docker plugin install juicedata/juicefs
```ini
[azure]
type = azureblob
account = xxxx
key = xxxx
endpoint = https://xxx
```

###### 1. Manual deployment
How to configure quickly? use `rclone config` command ? It need knows about a lot of things. Open [Doc](https://rclone.org/docs/), choose a instructions, like [Dropbox](https://rclone.org/dropbox/).
luojiyin1987 marked this conversation as resolved.
Show resolved Hide resolved

Look for

```ini
[remote]
app_key =
app_secret =
token = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX_XXXX_XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

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:
It is the configuration for Dropbox.

```ini
STORAGE_TYPE =
BUCKET =
ACCESS_KEY =
SECRET_KEY =
[dropbox]
type = dropbox
app_key = xxxxxxxxx
app_secret = xxxxxxxxx
token = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX_XXXX_XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

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
15 changes: 12 additions & 3 deletions start-docker.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#! /usr/bin/env bash

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

docker-compose down -v --remove-orphans
docker-compose up -d
# get the current working directory
current_dir=$(pwd)

# get polyfill-cache full path
mount_point="${current_dir}/polyfill-cache"

# umount polyfill-cache dir
sudo umount "$mount_point"
luojiyin1987 marked this conversation as resolved.
Show resolved Hide resolved

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

docker image prune -a -f