需要的環境
- Docker 和 Docker Compose
- 任意 Web 伺服器
最速教程
為 Firefish 準備一個目錄:
1
| mkdir firefish && cd firefish
|
⚠️注意:近期 Firefish 更新頻繁,本文的docker-compose.yml已經過時,請蔘考官方倉庫中的docker-compose.example.yml和Notice for server administrators進行配置。
用你喜歡的文字編輯器建立docker-compose.yml:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
| version: "3"
services:
web:
image: registry.joinfirefish.org/firefish/firefish:stable-amd64
container_name: firefish_web
restart: unless-stopped
depends_on:
- db
- redis
### Uncomment one of the following to use a search engine
# - meilisearch
- sonic
ports:
- "6666:3000" # 6666換成需要的埠
networks:
- calcnet
# - web
environment:
NODE_ENV: production
volumes:
- ./files:/firefish/files
- ./.config:/firefish/.config:ro
redis:
restart: unless-stopped
image: redis:7.0-alpine
container_name: firefish_redis
networks:
- calcnet
volumes:
- ./redis:/data
db:
restart: unless-stopped
image: postgres:12.2-alpine
container_name: firefish_db
networks:
- calcnet
env_file:
- .config/docker.env
volumes:
- ./db:/var/lib/postgresql/data
### Only one of the below should be used.
### Meilisearch is better overall, but resource-intensive. Sonic is a very light full text search engine.
# meilisearch:
# container_name: meilisearch
# image: getmeili/meilisearch:v1.1.1
# environment:
# - MEILI_ENV=${MEILI_ENV:-development}
# ports:
# - "7700:7700"
# networks:
# - calcnet
# volumes:
# - ./meili_data:/meili_data
# restart: unless-stopped
sonic:
restart: unless-stopped
image: valeriansaliou/sonic:v1.4.0
logging:
driver: none
networks:
- calcnet
volumes:
- ./sonic:/var/lib/sonic/store
- ./sonic/config.cfg:/etc/sonic.cfg:ro
networks:
calcnet:
# web:
# external:
# name: web
|
你也可以用 Melisearch,但這是最速指南,只講 Sonic。
建立.config目錄:
1
| mkdir .config && cd .config
|
建立docker.env:
1
2
3
4
| # db settings
POSTGRES_PASSWORD=example-firefish-pass
POSTGRES_USER=example-firefish-user
POSTGRES_DB=firefish
|
建立default.yml:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| #━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Firefish configuration
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# After starting your server, please don't change the URL! Doing so will break federation.
# ┌─────┐
#───┘ URL └─────────────────────────────────────────────────────
# Final accessible URL seen by a user.
url: https://你的域名/
port: 3000
db:
host: db
port: 5432
#ssl: false
# Database name
db: firefish
# Auth
user: example-firefish-user
pass: example-firefish-pass
# ┌─────────────────────┐
#───┘ Redis configuration └─────────────────────────────────────
redis:
host: redis
port: 6379
# ┌─────────────────────┐
#───┘ Sonic configuration └─────────────────────────────────────
sonic:
host: sonic
port: 1491
auth: SecretPassword
collection: notes
bucket: default
# Reserved usernames that only the administrator can register with
reservedUsernames: ["root", "admin", "administrator", "me", "system"]
signToActivityPubGet: true
|
回到上一層目錄,建立./sonic/config.cfg:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| # Sonic
# Fast, lightweight and schema-less search backend
# Configuration file
# Example: https://github.com/valeriansaliou/sonic/blob/master/config.cfg
[server]
log_level = "debug"
[channel]
inet = "0.0.0.0:1491"
tcp_timeout = 300
auth_password = "SecretPassword"
[channel.search]
query_limit_default = 10
query_limit_maximum = 100
query_alternates_try = 4
suggest_limit_default = 5
suggest_limit_maximum = 20
list_limit_default = 100
list_limit_maximum = 500
[store]
[store.kv]
path = "./data/store/kv/"
retain_word_objects = 1000
[store.kv.pool]
inactive_after = 1800
[store.kv.database]
flush_after = 900
compress = true
parallelism = 2
max_files = 100
max_compactions = 1
max_flushes = 1
write_buffer = 16384
write_ahead_log = true
[store.fst]
path = "./data/store/fst/"
[store.fst.pool]
inactive_after = 300
[store.fst.graph]
consolidate_after = 180
max_size = 2048
max_words = 250000
|
全部建立好以後的目錄結構應該看起來像這樣:
1
2
3
4
5
6
7
| .
├── .config
│ ├── default.yml
│ └── docker.env
├── docker-compose.yml
└── sonic
└── config.cfg
|
最後執行docker compose up,繫結域名、反代埠,例項就搭建完成了。
Firefish 已經自動 Minify 了所有的前端檔案,如果你使用 Cloudflare 或其他類似的服務,記得關掉 Auto Minify,否則會出現一些奇怪的問題。
以上就是最速教程。
一些問題
Q:docker.env和./sonic/config.cfg密碼和用戶名稱不改沒問題嗎?
A:沒很大問題,因為兩個服務沒有暴露到公網上,僅做個人使用不改也沒什麼大事。
Q:為什麼 network 要叫calcnet?
A:因為這個專案本來叫做 Calckey。
評論已停用,直到您接受功能性 Cookie。