Featured image of post 最速 Firefish 部署指南

最速 Firefish 部署指南

才不是最水指南(

需要的环境

  • Docker 和 Docker Compose
  • 任意 Web 服务器

最速教程

为 Firefish 准备一个目录:

1
mkdir firefish && cd firefish

⚠️注意:近期 Firefish 更新频繁,本文的docker-compose.yml已经过时,请参考官方仓库中的docker-compose.example.ymlNotice 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
46
47
48
49
50
51
52
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# 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
67
68
69
# 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,否则会出现一些奇怪的问题。1

以上就是最速教程。

一些问题

Q:docker.env./sonic/config.cfg密码和用户名不改没问题吗?

A:没很大问题,因为两个服务没有暴露到公网上,仅做个人使用不改也没什么大事。

Q:为什么 network 要叫calcnet

A:因为这个项目本来叫做 Calckey。