fly.io 可以直接运行 docker 镜像.

1.创建一个 Volumes 存储卷

1
2
// 地区: hkg; 大小: 1GB
fly volumes create myapp_data --region hkg --size 1

2.flyctl launch --image finab/bark-server配置好 appName 后,直接启动一个 bark 服务器

在客户端直接添加 https://appName.fly.dev 即可

3.服务直接暴露在公网.

我们可以通过在fly.toml [env] 配置环境变量开启 Basic Auth
如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
app = "appName"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
image = "finab/bark-server"

[env]
BARK_SERVER_BASIC_AUTH_USER = "user"
BARK_SERVER_BASIC_AUTH_PASSWORD = "password"
BARK_SERVER_DATA_DIR = "/bark_server_data"

日志中输出:

[info] 2022-11-27 23:58:00 INFO Bark Server Has Basic Auth Enabled. [info] 2022-11-27 23:58:00 INFO init database [/bark_server_data]...

则代表启动成功.

通过 v2 版本接口测试一下

如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
curl -u user:password --request POST \
--url https://fly-bark-server.fly.dev/push \
--header 'Content-Type: application/json; charset=utf-8' \
--data '{
"body": "test body",
"device_key": "device_key",
"title": "test title",
"badge": 1,
"category": "tips",
"sound": "minuet.caf",
"icon": "https://day.app/assets/images/avatar.jpg",
"group": "test",
"url": "https://mritd.com"
}'