写在前面
被补充文章的链接:使用 Docker 最小化部署 Misskey。
本文主要起补充作用,大致的流程上面的文章已经讲的很清楚了,这里主要整理一下遇到的坑。
如果你遇到了下文中没有提到的错误,比如无法订阅中继,建议按照官方文档的流程构建镜像,而不是按照上面的文章使用现有的镜像。构建镜像时如果爆内存本文有解决方式。
数据库初始化失败
症状
运行下面的命令时出错,报错信息中包含应该能看见这段信息:getaddrinfo ENOTFOUND db 。
docker-compose run --rm web yarn run init
解决
尝试手动启动 redis 和 db 两个容器,等待容器内的数据库就绪后重新运行数据库初始化命令。等待时间只能自己把握,不放心就等个几分钟应该就可以了。
原因
这是因为数据库容器内的数据库服务在运行数据库初始化命令时并未就绪。截止至截稿日,最新的版本是 v12.69.0,官方提供的文档中并未提醒这一情况。
官方提供的容器编排文件 docker-compose.yml
通过 links
配置规定了容器的启动顺序,但是这并不能保证容器内的数据库服务已经就绪。这一点 Docker 在官方文档中有提醒。
You can control the order of service startup and shutdown with the depends_on option. Compose always starts and stops containers in dependency order, where dependencies are determined by
depends_on
,links
,volumes_from
, andnetwork_mode: "service:..."
.However, for startup Compose does not wait until a container is “ready” (whatever that means for your particular application) – only until it’s running. There’s a good reason for this.
The problem of waiting for a database (for example) to be ready is really just a subset of a much larger problem of distributed systems. In production, your database could become unavailable or move hosts at any time. Your application needs to be resilient to these types of failures.
Control startup and shutdown order in Compose | Docker Documentation
Misskey 官方已经发现了这个问题:Error: getaddrinfo ENOTFOUND でプロセスが落ちる · Issue #1546 · syuilo/misskey。
构建镜像时爆内存
症状
运行下面这行命令后显示堆内存不足。
docker-compose build
解决
修改镜像构建的指导文件 Dockerfile
,修改命令 yarn build
为下面的命令,然后重新构建镜像。
export NODE_OPTIONS="--max-old-space-size=2048" && yarn build
原因
主要是因为 WebPack 在 build 时会有一个内存占用的峰值。[1]这一问题截止至截稿日官方的中英文文档也并未提醒。Github 已经有用户开 issue 提出了文档修改建议:Clarify hardware requirements in the installation guide · Issue #4983 · syuilo/misskey。
我曾经以为是单纯的内存不足,一度把 swap 增加到 10GB 还不行才反应过来没准是其它原因。
写在最后
在 Github 读日文 issue 做不到啊。
大佬,管理员账号怎么注册啊,我搭建完成没有让我设置管理员账号呀,然后命令号又提示找不到